Here you can find the source of getOrCreateList(Map
public static <K, T> List<T> getOrCreateList(Map<K, List<T>> map, K key)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static <K, T> List<T> getOrCreateList(Map<K, List<T>> map, K key) { List<T> set = map.get(key); if (set == null) { set = new ArrayList<T>(); map.put(key, set);/*from w ww. j a v a2 s . c o m*/ } return set; } }