String comparison confused

后端 未结 3 527
执笔经年
执笔经年 2021-01-22 16:24

Before we move on: I understand we should use .equals() to compare content. I am now just talking about if the actual references are the same for the following scenario.

3条回答
  •  遇见更好的自我
    2021-01-22 17:06

    Always use equals method for comparing strings. The trouble about interning is that each version of JDK does it a bit differently, so I wouldn't have counted on that unless you want to call intern every time on the string.

提交回复
热议问题