Java Map remove by key value pair

Description

Java Map remove by key value pair

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");

    System.out.println(hMap);//from  w  w w  .  j  a v  a 2 s .co m
    
    hMap.remove("1","Not Exist");
    System.out.println(hMap);

    hMap.remove("1","CSS");
    System.out.println(hMap);

  }
}



PreviousNext

Related