java - 如果Java没有运算符重载, "string1"+ "string2"怎么可能?

标签 java string operator-overloading string-concatenation

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/

相关文章:

c# - public static float [ ] operator/( float [ ] a , int b ) 无法编译

java - 使用 Android MediaCodec 进行视频转码

java - 部署可以自行停止吗?

string - 带有希腊字符的matlab字符串

java - 在矩形内创建字符串

C++:自动生成(默认)复制构造函数

c++ - 在 C++ 中,使用 operator<< 构造函数的输入

java - Java 中的 Ldap 绑定(bind)使用用户名而不是 DN

java - 使用 java - ref 的 JSON 模式验证

sql-server - Sqoop Hive 字符串数据类型到 MS SQL Server 类型