logo CodeStepByStep logo

hasDuplicateValue

Language/Type: Java Map collections
Related Links:

Write a method named hasDuplicateValue that accepts a Map from strings to strings as a parameter and returns true if any two keys map to the same value. For example, if a map named m stores {Marty=Stepp, Stuart=Reges, Jessica=Miller, Amanda=Camp, Meghan=Miller, Hal=Perkins}, the call of hasDuplicateValue(m) would return true because both "Jessica" and "Meghan" map to the value "Miller". Return false if passed an empty or one-element map. Do not modify the map passed in.

Method: Write a Java method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.