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 addToValueList(Map<K, List<V>> map, K key, V value) { List<V> valueList = map.get(key); if (valueList == null) { valueList = new ArrayList<V>(); map.put(key, valueList); } valueList.add(value); } }