map的赋值:
if (map.get(key) == null) { map.put(key, 1); } else { map.put(key, map.get(key) + 1); }
map的遍历:
Map<String, Integer> map = new TreeMap<String, Integer>(); Iterator iter = map.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<String, Integer> entry = (Entry<String, Integer>) iter.next(); String key = entry.getKey(); int val = entry.getValue(); }
。