Multiple objects having same hash are stored as LinkedList
and new elements are added at HEAD
. So in your case since all have the same hash, LinkedList is in following order:
Martin->Peter->Alex.
When you add another "Alex" the list is traversed from HEAD.
To test:
public boolean equals(Object obj)
{
Employee e1=(Employee)obj;
System.out.println(this.name + "'s equals has just been called against " + e1.name );
return ((name.equals(e1.name)) && (empid==e1.empid));
}