Here you can find the source of removeAllNullValueEntry(Map
public static <R, T> Map<R, T> removeAllNullValueEntry(Map<R, T> source)
//package com.java2s; //License from project: Apache License import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; public class Main { public static <R, T> Map<R, T> removeAllNullValueEntry(Map<R, T> source) { if (null == source) { return new HashMap<R, T>(); }//w ww . j av a 2 s . co m Map<R, T> map = new HashMap<R, T>(); for (Entry<R, T> entry : source.entrySet()) { if (null == entry.getValue() || null == entry.getKey()) { continue; } map.put(entry.getKey(), entry.getValue()); } return map; } }