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
Certainly Lets break down the steps and implement the MapIntersectClient class with the mapIntersect method This will help you understand how to creat... View full answer
Get step-by-step solutions from verified subject matter experts
