MAP中存在相同的键

 1 public class MultiMap {
 2 
 3     private HashMap<String, List<String>> maps = new HashMap<String, List<String>>();
 4 //创建put方法 
 5     public void put(String key, String value) {
 6         //如果此映射不包含对于指定键的映射关系
 7         if (!maps.containsKey(key)) {
 8             maps.put(key, new ArrayList<String>());
 9         }
10         maps.get(key).add(value);
11     }
12     public List<String> get(String key){
13         if(maps.containsKey(key)){
14             return maps.get(key);
15         }else{
16             return new ArrayList<String>();
17         }
18     }
19     
20     public Set<String> keySet(){
21         return maps.keySet();
22     }
23 }
原文地址:https://www.cnblogs.com/liangdelin/p/2789453.html