How does the String class override the + operator?

前端 未结 7 1992
刺人心
刺人心 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:36

    How String class overrides + operator?

    It doesn't. The compiler does it. Strictly speaking, the compiler overloads the + operator for String operands.

提交回复
热议问题