Java == for String objects ceased to work?

前端 未结 11 1207
情深已故
情深已故 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:45

    Source code literals are part of a constant pool, so if the same literal appears multiple times, it will be the same object at runtime.

提交回复
热议问题