//没有重构equals方法。 //Cat.java public class Cat{} //Program.java public class Program{ public static void main(String[] args){ Cat cat1 = new Cat(); Cat cat2 = new Cat(); System.out.println(cat1.equals(cat2)); //false String s1 = new String(); String s2 = new String(); System.out.println(s1.equals(s2)); // 同样是对象,此处为何是true ? } }
yanrun
相关分类