What is the result of the following?
List<String> list = new ArrayList<>(); list.add("Austin"); list.add("Boston"); list.add("San Francisco"); list.removeIf(a -> a.length() > 10); System.out.println(list.size());
B.
On a stream, the filter()
method only keeps values matching the lambda.
The removeIf()
does the reverse on a Collection and keeps the elements that do not match.
In this case, that is Austin and Boston so Option B is correct.