import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; public class map { public static void main(String[] args){ Map<Integer,String> map = new HashMap<Integer,String>(); method_3(map); } public static void method_3(Map<Integer,String> map){ map.put(3, "xiaoming"); map.put(8, "xiaoqiang"); map.put(5, "dazhang"); map.put(9, "wuming"); Set<Map.Entry<Integer, String>> entryset = map.entrySet(); Iterator<Map.Entry<Integer, String>> it = entryset.iterator(); while(it.hasNext()){ Map.Entry<Integer, String> me = it.next(); Integer key = me.getKey(); String value = me.getValue(); System.out.println(key+"::"+value); } } }