Here you can find the source of put(Map
private static void put(Map<String, List<Object>> multiValueMap, String key, Object value, boolean single)
//package com.java2s; import java.util.*; public class Main { private static void put(Map<String, List<Object>> multiValueMap, String key, Object value, boolean single) { synchronized (multiValueMap) { // save calling code some headaches if (value == null) { if (single) multiValueMap.remove(key); return; }// ww w .j a va 2 s . c o m List<Object> values = multiValueMap.get(key); if (values == null) { values = new ArrayList<Object>(); multiValueMap.put(key, values); } else if (single) values.clear(); values.add(value); } } public static void add(Map<String, List<Object>> multiValueMap, String key, Object value) { put(multiValueMap, key, value, false); } }