Worked example
Map<String, Integer> ages = new HashMap<String, Integer>();
ages.put("Ada", 30);
ages.put("Sam", 25);
int total = 0;
for (String key : ages.keySet()) { // visit each key
total = total + ages.get(key); // add its value
}
System.out.println(total); // 55
The sum is the same no matter what order the keys are visited in.