|
|
|
|
|
by sah2ed
2245 days ago
|
|
That’s because the language designers overloaded the arithmetic operator (+) to perform string concatenation when the operands can be cast as Strings. Without overloading the + operator, string concatenation which is a common operation, would have been unnecessarily verbose. Your example without the + operator would look like below: String a = new String(“a”).concat(1); // String object concat
String a = “a”.concat(1); // String literal concat
|
|