import java.util.LinkedHashMap; import java.util.Map; public class Demo { public static void main(String[] args) { Map<String, Integer>map = new LinkedHashMap<>(); map.put("Jack", 0); map.put("Tim", 1); map.put("David", 2); map.put("Tom", 3); map.put("Kevin", 4); map.put("Jeff", 5); map.put("Katies", 6); map.put("Steve", 7); map.put("Andrew", 8); map.put("Angelina", 9); for (Map.Entry<String, Integer>entry: map.entrySet()) { System.out.println(entry.getKey() + " => " + entry.getValue()); } } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more