You don't control the order you get the keys in a HashMap. Maps aren't really designed for sequential iteration- instead, they're designed to make "give me this thing that might be in the middle...