Worked example
Map<String, Integer> ages = new HashMap<String, Integer>();
ages.put("Ada", 30);
ages.put("Sam", 25);
System.out.println(ages.get("Ada")); // 30
ages.put("Ada", 31); // overwrites
System.out.println(ages.get("Ada")); // 31
System.out.println(ages.size()); // 2 — still two keys
The keys are unique; size() is the number of pairs.