Originally posted by Edwin Dalorzo: As the previous post states, the first key of a HashMap may not necesarily be the firt entry you put into the HashMap, since HashMap do not keep an specific order. That being said, you can also obtain the first key in different ways. Another way to do it is:
HashMap map = new HashMap();
Object firstKey = map.keySet().toArray()
I hope this helps!
If the collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.