String x = "abc";
String y = new String("abc");
String a = "abcd";
String b = "abcd";
System.out.println("a == b : "+(a == b)); // true
System.out.println("a.equals(b) : "+(a.equals(b))); // true
String c = new String("abcd");
String d = new String("abcd");
System.out.println("c == d : "+(c == d)); // false
System.out.println("c.equals(d) : "+(c.equals(d))); // true
String c = new String("abcd").intern();
String d = new String("abcd").intern();
System.out.println("c == d : "+(c == d)); // true
System.out.println("c.equals(d) : "+(c.equals(d))); // true (JDK1.7)
原文:http://blog.csdn.net/sunnyyoona/article/details/50421059