What happens when executing
String s = "str" + 2;
Is there a method of String
class that correspond exactly to the +
operator?
From Java Language Specification (emphasis mine):
If only one operand expression is of type String, then string conversion (§5.1.11) is performed on the other operand to produce a string at run time. The result of string concatenation is a reference to a String object that is the concatenation of the two operand strings.