10.2. Operator overloading

Operator overloading is a new concept to Java developers since Java doesn't allow operator overloading. [3], [4]

[3] Some Java programmers may want to argue that the + operator in Java is a pseudo-overloaded operator when it is used for concatenating strings. This is a special case whereby the compiler actually decides if you are doing a numerical addition or a string concatenation depending on the operand types, and hence shows a little 'operator overloading' behavior.

[4] Operator overloading is a feature in C++ though.

In brief, operator overloading allows you to write special methods (called operators, or operator methods) which are invoked when an overloaded operator is used to perform an operation on one or more ...

Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.