import java.util.HashMap; import java.util.Map; class Main { public static void main(String[] args) { Mapmap = new HashMap<>(); map.put("apple", 1); map.put("banana", 2); map.put("orange", 3); System.out.println(map.containsKey("apple")); // true System.out.println(map.containsKey("grape")); // false } }
import java.util.Map; import java.util.TreeMap; class Main { public static void main(String[] args) { MapThe package library for java.util Map is java.util.map = new TreeMap<>(); map.put("apple", 1); map.put("banana", 2); map.put("orange", 3); System.out.println(map.containsKey("orange")); // true System.out.println(map.containsKey("cherry")); // false } }