The same pairs

Report a typo

You're working with the two maps that contain String keys and String values.

You need to implement the calcTheSamePairs method. It should print how many common pairs both maps contain. The pair is considered to be the same when the element from the first map has the same key and the same value as the element from the second map.

Example:

map1:                 map2:
keyA valueA           key1 value1
keyB valueB           keyA valueA 
keyC valueC           key2 value2
keyD valueD           keyB valueB
keyE valueE

Your output:

2
Write a program in Java 17
import java.util.*;


class MapFunctions {

public static void calcTheSamePairs(Map<String, String> map1, Map<String, String> map2) {
// write your code here

}
}
___

Create a free account to access the full topic