Maximilian
Lifer
Ive never really understood how to use this properly. I have a HashMap full of Employee objects and im looking to extract the individual Employee objects and put them into a TreeSet.
I just seem to end up with a aSortedSet that has another collection inside it rather than the individual values from anUnsortedMap. What am i doing wrong? 😕
Code:
TreeSet<Employee> aSortedSet = new TreeSet<Employee>();
Iterator<Employee> aCollectionIterator = anUnsortedMap.values().iterator();
while (aCollectionIterator.hasNext())
{
aSortedSet.add(aCollectionIterator.next());
}
I just seem to end up with a aSortedSet that has another collection inside it rather than the individual values from anUnsortedMap. What am i doing wrong? 😕