Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; import java.util.Map; public class Main { public static <K, V> void putMapList(Map<K, List<V>> map, K key, V val) { if (!map.containsKey(key)) { map.put(key, new ArrayList<V>()); } List<V> list = map.get(key); list.add(val); } }