In this program, you will create a program to read input, create a hashmap, and display value. The Hashmap has an Integer key and a String value denoting a student id and name. The program searches whether a key and determines whether the key-value pair is present if present it displays the value or else displays -1
The goal of the program is to practice the basics of collections in java.
The first line of the input is an integer that represents the number of key-value pairs to
be input in the Hashmap. The second line consists of the number of key-value pairs.
The third line consists of the key to be searched for.
Complete the function main in the editor below. The function must print the value if
the key is present otherwise display-1
. Read the input from the console
Create Hashmap with given input values • Check whether the given key is present or not. Print the value if the key is present otherwise display -1
Input Format For Custom Testing
The first line contains an integer, n, denoting the number of elements in
Each line / of the n subsequent lines
(where 0 si<n) contains a key-value pair separated by a space. The last line contains the key to be
101 John Doe
102 John Doe
The result displayed is -1 because there is no key-value pair with a key value of 105.
Sample case 1
The result displayed is "Epsilon" because
there is key-value pair with a key value of
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)