Which of the following cannot fill in the blank to make the code compile?
private void output(___ <?> x) { x.forEach(System.out::println); }
C.
The forEach()
method that takes one parameter is defined on the Collection interface.
A map is not a Collection.
There is a version of forEach()
defined on the Map interface, but it uses two parameters.
Since two parameters can't be used with a method reference, Option C is the answer.