How does the String class override the + operator?

前端 未结 7 2025
刺人心
刺人心 2020-11-22 12:25

Why in Java you\'re able to add Strings with the + operator, when String is a class? In theString.java code I did not find any implementation for this operator

7条回答
  •  庸人自扰
    2020-11-22 12:49

    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.

提交回复
热议问题