import java.util.HashMap; import java.util.Iterator; import java.util.Set; public class Demo { public static void main(String[] args) { HashMap<Integer, String>map = new HashMap<Integer, String>(); map.put(10, "A"); map.put(20, "B"); map.put(30, "C"); map.put(40, "D"); map.put(50, "E"); map.put(60, "F"); map.put(70, "G"); map.put(80, "H"); Set<Integer>set = map.keySet(); Iterator<Integer>i = set.iterator(); while (i.hasNext()) { Integer res = i.next(); System.out.println(res + ": " + map.get(res)); } } }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more