Map取值技巧

   Map map = new HashMap();
	  map.put("1", "one");
	  map.put("2", "two");
	  map.put("3", "three");
	  
	  Set keys = map.keySet();
	  Set keys2 = map.entrySet();
	  for(Iterator it = keys.iterator(); it.hasNext();) {
		  String key = (String)it.next();
		  String value = (String) map.get(key);
		  System.out.println(key + " " + value);
	  }
	  for(Iterator it2 = keys2.iterator();it2.hasNext();) {
		  Map.Entry e = (Map.Entry)it2.next();
		  Object k = e.getKey();
		  Object v = e.getValue();
		  System.out.println(k + " " + v);
	  }

你可能感兴趣的:(map)