String a = "Hello";
String b = "Hello";
String c = new String("Hello");
String d = new String("Hello");
System.out.println(a == b); true
System.out.println(b == c); false
System.out.println(c == d); false
System.out.println(a.equals(b)); true
System.out.println(b.equals(c)); true
System.out.println(c.equals(d)); true
java中对于字符串的存储是比较特殊的,分成两个区域存储(这两个区域都在堆中)
一:字符串常量池,
二:另一个就是字符串对象区域,