1.==比较问题
String a = "hello";
String b = "hello";
String c = "he" + "llo";
String d = "he" + new String("llo");
a == b //1
a == c //2
a == d //3
首先公布答案,式子1返回true,式子2返回true,式子3返回false
式子1很好理解,由于存在字面量池,在用字面量赋值时,如果池中已经有了相同的字面量,就不会
String a = "hello";
String b = "hello";
String c = "he" + "llo";
String d = "he" + new String("llo");
a == b //1
a == c //2
a == d //3
首先公布答案,式子1返回true,式子2返回true,式子3返回false
式子1很好理解,由于存在字面量池,在用字面量赋值时,如果池中已经有了相同的字面量,就不会