subject

What is wrong with the given method called intersect that is supposed to take two Maps of strings to integers as parameters and return a new map whose contents are the intersection of the two. The intersection of two maps is defined here as the set of keys and values that exist in both maps. So if some key K maps to value V in both the first and second maps, include it in your result. If K does not exist as a key in both maps, or if K does not map to the same value V in both maps, exclude that pair from your result. For example, consider the following two maps: {J=87, L=62, W=46, A=100, S=80, J=88, K=52, S=95}
{L=62, K=52, W=52, J=88, S=80, B=60, L=83, S=87}
Calling intersect on the preceding maps would return the following new map (the order of the key/value pairs does not matter):

{L=62, S=80, J=88, K=52}

Correct the following code by rewriting the correct answer in your textbox:

public static Map intersect(Map m1,
Map m2){
Set m2Set= new HashSet<>(m2.keySet());// get the keys of map 1
Set m1Set= new HashSet<>(m1.keySet());// get the keys of map 2
m1Set. retainAll(m2Set);
return m1;
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:00
What is the name of the option in most presentation applications with which you can modify slide elements? 1. the option enables you to modify a slide element in most presentation applications.
Answers: 3
question
Computers and Technology, 22.06.2019 22:50
Which is the best minecraft server? a. mineplex b. worldonecraft c. 9b9t d. 2b2t
Answers: 2
question
Computers and Technology, 23.06.2019 23:30
What can you prevent issues related to downloading content form the internet
Answers: 1
question
Computers and Technology, 25.06.2019 01:30
What was the advantage of using transistors instead of vacuum tubes in the second-generation computers? a. computers were drastically reduced in size. b. computers no longer produced errors. c. computers became affordable. d. computers could run on electricity.
Answers: 1
You know the right answer?
What is wrong with the given method called intersect that is supposed to take two Maps of strings to...
Questions
question
Mathematics, 02.09.2019 03:30
question
Mathematics, 02.09.2019 03:50
question
Social Studies, 02.09.2019 03:50
Questions on the website: 13722367