Here you can find the source of removeFromMap( Map
public static <K, V, C extends Collection<V>> boolean removeFromMap( Map<K, C> map, K key, V value)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Map; public class Main { public static <K, V, C extends Collection<V>> boolean removeFromMap( Map<K, C> map, K key, V value) { C collection = map.get(key);//from w w w .j av a 2s. co m if (collection == null) { return false; } boolean success = collection.remove(value); if (success && collection.size() == 0) { return map.remove(key) != null; } return success; } }