Java Map remove key value pair by key
import java.util.HashMap; import java.util.Map; public class Main { public static void main(String[] args) { Map<String,String> hMap = new HashMap<String,String>(); hMap.put("1", "CSS"); hMap.put("2", "HTML"); hMap.put("3", "Java"); //ww w.ja va 2 s . c om System.out.println(hMap); String obj = hMap.remove("2"); System.out.println(obj + " Removed from HashMap"); } }