B
bassel
greeting everyone,
I have a problem with sets, according to the API documentation
Class TreeSet<E>
---------------------------
public boolean add(E e)
Adds the specified element to this set if it is not already
present. More formally, adds the specified element e to this set if the
set contains no element e2 such that (e==null ? e2==null :
e.equals(e2)). If this set already contains the element, the call
leaves the set unchanged and returns false.
new I have this code:
-----------------------------
Set identities = new java.util.TreeSet<Identity>();
System.out.println(id1.equals(id2));
System.out.println(identities.add(id1));
System.out.println(identities.add(id2));
output is:
------------
true
true
true
where's the problem???
regards,
Bassel
I have a problem with sets, according to the API documentation
Class TreeSet<E>
---------------------------
public boolean add(E e)
Adds the specified element to this set if it is not already
present. More formally, adds the specified element e to this set if the
set contains no element e2 such that (e==null ? e2==null :
e.equals(e2)). If this set already contains the element, the call
leaves the set unchanged and returns false.
new I have this code:
-----------------------------
Set identities = new java.util.TreeSet<Identity>();
System.out.println(id1.equals(id2));
System.out.println(identities.add(id1));
System.out.println(identities.add(id2));
output is:
------------
true
true
true
where's the problem???
regards,
Bassel