Operator overloading in Java

前端 未结 10 1914
独厮守ぢ
独厮守ぢ 2020-11-21 23:51

Please can you tell me if it is possible to overload operators in Java? If it is used anywhere in Java could you please tell me about it.

10条回答
  •  滥情空心
    2020-11-22 00:27

    In addition to all the people pointing out that + is overloaded for Strings, - is also overloaded for both floating point and integer operations, as are * and /.

    [edit] % is also overloaded for floating point, which can be a bit of a surprise for those with a C or C++ background.

提交回复
热议问题