Question: Write the output produced when the following method is passed each of the following maps: a. {sheep=wool, house=brick, cast=plaster, wool=wool} b. {ball=blue, winkie=yellow, corn=yellow, grass=green,

Write the output produced when the following method is passed each of the following maps:

public static void mystery (Map m) { Set s new TreeSet () ; for (String key : m.keySet ()) { if (!m.get (key) .equals (key)) { s.add (m.get (key)); } else { s.remove (m.get (key)); System.out.println (s);

a. {sheep=wool, house=brick, cast=plaster, wool=wool}

b. {ball=blue, winkie=yellow, corn=yellow, grass=green, emerald=green}

c. {pumpkin=peach, corn=apple, apple=apple, pie=fruit, peach=peach}

d. {lab=ipl, lion=cat, corgi=dog, cat=cat, emu=animal, nyan=cat}

public static void mystery (Map m) { Set s new TreeSet () ; for (String key : m.keySet ()) { if (!m.get (key) .equals (key)) { s.add (m.get (key)); } else { s.remove (m.get (key)); System.out.println (s);

Step by Step Solution

3.59 Rating (167 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Output produced when the ... 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!