注:
1. equals() 判断对象内容
2. == 判断对象引用
例子:
public void test03(){
String cString="abc";
String aString=new String("abc");
String bString=new String("abc");
String dString=aString;
System.out.println(1==1);
System.out.println(aString==bString);
System.out.println(aString==cString);
System.out.println(aString.equals(cString));
System.out.println(aString==dString);
System.out.println(aString.equals(dString));
System.out.println(aString.equals(bString));
}
结果是:
true
false
false
true
true
true
true