BJP3 Self-Check 11.21: mapMystery3

Language/Type: Java Collection mystery Sets and Maps
Author: Marty Stepp (on 2013/04/01)

Write the output that is printed when the given method below is passed each of the following pairs of maps as its parameter. Assume that each parameter map stores its key/value pairs in exactly the order shown, and that is the order in which a for-each loop would examine them. Recall that maps print in a {key1=value1, key2=value2, ..., keyN=valueN} format. Your answer should display the right keys and values in the right order.

```public Map<String, String> mystery(Map<String, Integer> map1, Map<Integer, String> map2) {
Map<String, String> result = new TreeMap<String, String>();
for (String s1 : map1.keySet()) {
if (map2.containsKey(map1.get(s1))) {
result.put(s1, map2.get(map1.get(s1)));
}
}
return result;
}
```
 `map1={bar=1, baz=2, foo=3, mumble=4}; map2={1=earth, 2=wind, 3=air, 4=fire}` `map1={five=105, four=104, one=101, six=106, three=103, two=102}, map2={99=uno, 101=dos, 103=tres, 105=quatro}` `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}`

You must log in before you can solve this problem.

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.