From the Javadoc: HashMap “class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time.”
If you need consistent ordering, you can use LinkedHashMap (for insertion/access order), or TreeMap (for comparision order). Please note, that these maintain the order of the keys, not the values.