Home Segments Top Top Previous Next

123: Sidetrip

Although Java allows you to define your own overloaded methods, you cannot define your own overloaded operators. In this respect, Java differs from C++, which allows you to overload both method and operators.

Java itself comes with overloaded operators, however. The use of the + operator for concatenation is a conspicuous example. The use of the + operator for adding together all sorts of arithmetic types is a less conspicuous example.