How do I iterate through a hashmap (containing objects of type Person) and calling methods on the Person object?
I used:
for(Iterator it = hashmap.entrySet().iterator(); is.hasNext();){
Person p = (Person)it.next();
p.doSomething();
}
but when the Person cast is being performed it says the object cannot be cast to a Person object (however it definitely is a subtype of Person).
java.util.HashMap$Entry cannot be cast to Person.
EDIT this is 1.4!
As your iterator will be walking through Map.Entry objects, extract them out as those types first: