Here you can find the source of putAsCollection(K key, V value, Map
@SuppressWarnings("unchecked") public static <K, V, L extends Collection<V>> void putAsCollection(K key, V value, Map<K, L> map)
//package com.java2s; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; public class Main { @SuppressWarnings("unchecked") public static <K, V, L extends Collection<V>> void putAsCollection(K key, V value, Map<K, L> map) { List<V> list = new ArrayList<V>(); if (map.containsKey(key)) { list = (List<V>) map.get(key); }/*from w ww . ja v a 2 s.c o m*/ list.add(value); map.put(key, (L) list); } }