1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| import java.util.HashMap; import java.util.Iterator; import java.util.Map;
public class TestMap03 { public static void main(String[] args) { Map<String, Object> map = new HashMap<String, Object>(); map.put("zhangsan", 20); map.put("lisi", 50); Iterator<Map.Entry<String, Object>> entries = map.entrySet().iterator(); while (entries.hasNext()) { Map.Entry<String, Object> entry = entries.next(); System.out.println(entry.getKey() + "\t" + entry.getValue()); } } }
|