标题: 关于HashSet大家帮忙看看输出是几? [打印本页] 作者: 轩辕迪卡 时间: 2013-11-8 08:57 标题: 关于HashSet大家帮忙看看输出是几? public class TestSet {
public static void main(String[] args) {
Set set = new HashSet();
Person p1=new Person();
Person2 p2=new Person2();
set.add(p1);
set.add(p2);
System.out.println(set.size());
}
}
class Person {
@Override
public boolean equals(Object obj) {
return true;
}
}
public class Person2 {
@Override
public boolean equals(Object obj) {
return true;
}
}