class StringEqualTest {
public static void main(String[] args) {
String s1 = "Programming";//栈
String s2 = new String("Programming");//栈
String s3 = "Program";//常量
String s4 = "ming";//常量
String s5 = "Program" + "ming";//栈
String s6 = s3 + s4;//常量
System.out.println(s1 == s2);//false
System.out.println(s1 == s5);//
System.out.println(s1 == s6);
System.out.println(s1 == s6.intern());
System.out.println(s2 == s2.intern());//这句话等价于s2==s1当然是false
}
}
false
true
false
true
false
http://www.cnblogs.com/dolphin0520/p/3811437.html
理解java抽象类和接口
http://www.cnblogs.com/dolphin0520/p/3811437.html