Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Map; public class Main { public static void clearNullElement(Map map) { if (map == null) return; Object[] vs = map.keySet().toArray(); for (Object o : vs) { if (null == map.get(o)) map.remove(o); } } }