String compare
有些对象重写了Object.equals() 方法 String,Date,Byte,Integer,Short,Character,Long,Float,Double,Boolean
public class Student { public static void main(String[] args) { String s1 = new String("123"); String s2 = new String("123"); String s3 = "123"; String s4 = "123"; System.out.println(s1 == s2); //false System.out.println(s1.equals(s2)); //true System.out.println(s3 == s4); //true System.out.println(s3.equals(s4)); //true } }

浙公网安备 33010602011771号