Question: What does the following output? A. [a, lamb, had, Mary, little] B. [a] C. [a, a] D. The code does not compile. E. The code
What does the following output?

A. [a, lamb, had, Mary, little]
B. [a]
C. [a, a]
D. The code does not compile.
E. The code throws an exception at runtime.
18: List list List.of( 19: "Mary", "had", "a", "little", "lamb"); 20: Set set = new HashSet (list); 21: set.addAll(list); 22: for (String sheep : set) if (sheep.length() > 1) set.remove(sheep); 23: 24: 25: System.out.println(set); =
Step by Step Solution
3.54 Rating (154 Votes )
There are 3 Steps involved in it
The code snippet provided in the image is trying to create a List of Strings convert it into a Set a... View full answer
Get step-by-step solutions from verified subject matter experts
