本帖最后由 yp324 于 2013-6-4 19:53 编辑
public static void main()
{
Collection c = new HashSet();
Demo d1 = new Demo(1,2);
Demo d2 = new Demo(3,4);
Demo d3 = new Demo(5,6);
c.add(d1);
c.add(d2);
c.add(d3);
System.out.println(c.size());
d3.setY(9);
c.remove(d3);
System.out.println(c.size());
}
class Demo
{
int x,y;
Demo(intx,int y)
{
this.x=x;
this.y=y;
}
public void setY(int y)
(
this.y=y;
)
}
为什么两次的打印结果都为3
|