在下面的代码中,为什么它不调用o1.equals(o2);
即使并且引用类型的对象!equals(Object o)
equals(EqualsTest et)
o1
o2
EqualsTest
public class EqualsTest {
public static <T> boolean equalTest(T o1, T o2) {
return o1.equals(o2);
}
public static void main(String[] args) {
EqualsTest et1 = new EqualsTest();
EqualsTest et2 = new EqualsTest();
System.out.println(et1.equals(et2));
System.out.println(equalTest(et1, et2));
}
public boolean equals(Object o) {
if (o instanceof EqualsTest) {
System.out.println("equals(Object)");
return true;
}
return false;
}
public boolean equals(EqualsTest et) {
System.out.println("equals(EqualsTest)");
return this.equals((Object)et);
}
}