Question: Write the map returned when the following method is passed the following maps: a. map1: {bar=1, baz=2, foo=3, mumble=4}, map2: {1=earth, 2=wind, 3=air, 4=fire} b.

Write the map returned when the following method is passed the following maps:

public Map mystery (Map mapl, Map map2) { Map result = new TreeMap (); for (String sl : mapl.keySet ()) { if (map2.containsKey (mapl.get (sl))) { result.put (s1, map2.get (mapl.get (sl))) ; return result; }


a. map1: {bar=1, baz=2, foo=3, mumble=4}, map2: {1=earth, 2=wind, 3=air, 4=fire}

b. map1: {five=105, four=104, one=101, six=106, three=103, two=102}, map2: {99=uno, 101=dos, 103=tres, 105=quatro}

c. map1: {a=42, b=9, c=7, d=15, e=11, f=24, g=7}, map2: {1=four, 3=score, 5=and, 7=seven, 9=years, 11=ago}

public Map mystery (Map mapl, Map map2) { Map result = new TreeMap (); for (String sl : mapl.keySet ()) { if (map2.containsKey (mapl.get (sl))) { result.put (s1, map2.get (mapl.get (sl))) ; return result; }

Step by Step Solution

3.46 Rating (166 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Result returned when the mystery ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Building Java Programs A Back to Basics Approach Questions!