How do you search for a key in a HashMap? In this program, when the user enters a key the code should arrange to search the hashmap for the corresponding value and
HashMap
//If you want the key to be integer then you will have to declare the hashmap //as below :
HashMap map = new HashMap(); map.put(0, "x"); map.put(1, "y"); map.put(2, "z");
//input a integer value x
String value = map.get(x);