String operator +
Theres one special usage of an operator in Java: the + operator can be used to concatenate strings, as youve already seen. It seems a natural use of the + even though it doesnt fit with the traditional way that + is used. This capability seemed like a good idea in C++, so operator overloading was added to C++ to allow the C++ programmer to add meanings to almost any operator. Unfortunately, operator overloading combined with some of the other restrictions in C++ turns out to be a fairly complicated feature for programmers to design into their classes. Although operator overloading would have been much simpler to implement in Java than it was in C++, this feature was still considered too complex, so Java programmers cannot implement their own overloaded operators like C++ programmers can.
The use of the String + has some interesting behavior. If an expression begins with a String, then all operands that follow must be Strings (remember that the compiler will turn a quoted sequence of characters into a String):
int x = 0, y = 1, z = 2;
String sString = "x, y, z ";
System.out.println(sString + x + y + z);
Here, the Java compiler will convert x, y, and z into their String representations instead of adding them together first. And if you say:
System.out.println(x + sString);
Java will turn x into a String.