EventObject target = new EventObject("e2");
Set<EventObject> Following = o.getFollowingEvents(e1);
System.out.println("Elements : "+Following.toString());
System.out.println(e2.toString());
System.out.println(Following.toString()+" contains "+e2+" ? = "+Following.contains(target));
打印:
Elements : [e2, e5, end, T]
e2
[e2, e5, end, T] contains e2 ? = false
等于和比较:
@Override
public int compareTo(EventObject o) {
return this.getName().compareTo(o.getName());
}
@Override
public boolean equals(Object obj) {
return (obj instanceof EventObject) && (this.compareTo((EventObject) obj) == 0);
}
如果事件出现在Set?
,这怎么可能呢?