执行时会发生什么
String s = "str" + 2;
有没有String
的方法与 +
完全对应的类运算符?
最佳答案
来自Java Language Specification (强调我的):
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.
关于java - String + 运算符是如何实现的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24105989/