Strange behavior with string interning in Java

后端 未结 4 1656
别跟我提以往
别跟我提以往 2020-12-14 10:21

There is code as following:

String s = new String(\"1\");
s.intern();
String s2 = \"1\";
System.out.println(s == s2);

String s3 = new String(\"1\")+new          


        
4条回答
  •  一生所求
    2020-12-14 11:02

    Just for someone who use groovy, the addition info is: the behavior is different

提交回复
热议问题