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
You wrote
HashMap hashMap = new HashMap();
...
int x = scan.nextInt();
value = hashMap.get("x");
must be:
Map hashMap = new HashMap();
...
int x = scan.nextInt();
value = hashMap.get(x);
EDIT or without generics, like said in the comments:
int x = scan.nextInt();
value = (String) hashMap.get(new Integer(x));