Question: Find a HashMap value by searching for its key Write a static method findCapital ( ) that takes a HashMap and a String as parameters,

Find a HashMap value by searching for its key
Write a static method findCapital() that takes a HashMap and a String as parameters, and uses the String parameter as the key to find the value in the HashMap.
The return type is a String, which will be the value, if the key is valid.
If the key is not valid, print "Key Not Valid" and return null

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!