How does the String class override the + operator?

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

    The + operator is usually replaced by a StringBuilder at compile time. Check this answer for more details on that matter.

提交回复
热议问题