/** * @author lautturi.com * Java example: */ import java.util.*; public class Lautturi { public static void main(String[] args) { HashMap<String, Integer> map = new HashMap<>(); map.put("Apple", 21); map.put("Banana", 12); map.put("Cherry", 15); map.put("Orange", 35); for (Map.Entry<String, Integer> entry : map.entrySet()) { System.out.println(entry.getKey() + " = " + entry.getValue()); } } }
output:
Apple = 21 Cherry = 15 Orange = 35 Banana = 12