Here you can find the source of add(Map
public static void add(Map<String, List<Object>> multiValueMap, String key, Object value)
//package com.java2s; import java.util.*; public class Main { public static void add(Map<String, List<Object>> multiValueMap, String key, Object value) { put(multiValueMap, key, value, false); }/* w ww .j a v a 2 s . com*/ 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; } 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); } } }