String a = "hello";
String b = "hello";
String a = "hello";
String b = "hello";
String st1=new String("java");
String st2=new String("java");
System.out.println(st1==st2); false
System.out.println(a==b); true
System.out.println(a.equals(b)); true
System.out.println(st1.equals(st2)); true
==比较的是 栈 里的内容,new在堆里开辟了新的地址.
|
|