Java == for String objects ceased to work?

前端 未结 11 1268
情深已故
情深已故 2021-01-02 04:13
  public class Comparison {
        public static void main(String[] args) {
            String s = \"prova\";
            String s2 = \"prova\";
            System.         


        
11条回答
  •  悲哀的现实
    2021-01-02 04:44

    JLS, 3.10.5 => It is guaranteed that a literal string object will be reused by any other code running in the same virtual machine that happens to contain the same string literal

提交回复
热议问题