Question
Create a class MapIntersectClient and write a method mapIntersect in that class that accepts two maps whose keys are strings and whose values are integers
Create a class “MapIntersectClient” and write a method mapIntersect in that class that accepts two maps whose keys are strings and whose values are integers as parameters and returns a new map containing only the key/value pairs that exist in both of the parameter maps. In order for a key/value pair to be included in your result, not only do both maps need to contain a mapping for that key, but they need to map it to the same value. For example, if the two maps passed are {Janet=87, Logan=62, Whitaker=46, Alyssa=100, Stefanie=80, Jeff=88, Kim=52, Sylvia=95} and {Logan=62, Kim=52, Whitaker=52, Jeff=88, Stefanie=80, Brian=60, Lisa=83, Sylvia=87}, your method would return the following new map (the order of the key/value pairs does not matter): {Logan=62, Stefanie=80, Jeff=88, Kim=52}. Please write main method inside this class and create , initialize maps and pass them to the mapIntersect method and print the returned map.
Step by Step Solution
3.45 Rating (161 Votes )
There are 3 Steps involved in it
Step: 1
To determine To create a java program that maps the strings and displays the output accordingly Prog...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started