Keys get hashed into bucket slots. That's why a HashMap can find any value instantly — and why the order looks random.
put("TX", "Austin"), Java runs the key through a hash function to decide which of 16 buckets to store the value in. When you later call get("TX"), it hashes the same key and jumps directly to that bucket.
System.out.println(map). Adding the same 5 states in a different order produces the same bucket layout, because each key always hashes to the same slot.
Tip: try adding CT → Hartford, CA → Sacramento, TX → Austin from the presets and watch which buckets light up. Then try them in reverse order — same buckets.