"); //过滤掉key和value都为空的value //filterNull(map); map.entrySet().removeIf(e -> "".equals(e.getKey()) && "".equals(e.getValue())); System.out.println(map); } /** * 过滤value为null的数据 * @param map */ private static void filterNull(Map map) { Set> set = map.entrySet(); Iterator> it = set.iterator(); while(it.hasNext()) { Map.Entry me = (Entry) it.next(); if("".equals(me.getValue()) || me.getValue() == null) { it.remove(); } } }}