$ cat YourMap.java
public class YourMap extends HashMap
public void put(String key, Integer number) {
List
if (current == null) {
current = new ArrayList
super.put(key, current);
}
current.add(number);
}
public static void main(String args[]) { YourMap m = new YourMap(); m.put("a", 1); m.put("a", 2); m.put("b", 3); for(Map.Entry e : m.entrySet()) { System.out.println(e.getKey() + " -> " + e.getValue()); } }}$ java mapb -> [3]a -> [1, 2]

![具有重复键的Java映射[duplicate] 具有重复键的Java映射[duplicate]](http://www.mshxw.com/aiimages/31/508498.png)
