This question声明 Java 没有运算符重载。对此的回答指出 "a" + "b"
即使这看起来真的像一个重载的 +
也是可能的。我的问题很简单:如果 +
只能对数字求和并且不能重载,"a" + "b"
怎么可能? ( string + string
) 可能有效吗?
最佳答案
根据JavaDoc
The Java language provides special support for the string concatenation operator ( + ), and for conversion of other objects to strings. String concatenation is implemented through the StringBuilder(or StringBuffer) class and its append method. String conversions are implemented through the method toString, defined by Object and inherited by all classes in Java.
关于java - 如果Java没有运算符重载, "string1"+ "string2"怎么可能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32684660/