What is the output of the following?
public class Compete { public static void main(String[] args) { Stream<Integer> is = Stream.of(8, 6, 9); Comparator<Integer> c = (a, b) -> a - b; is.sort(c).forEach(System.out::print); } }
C.
There is not a stream pipeline method called sort()
.
There is one called sorted()
.
Since the code does not compile, Option C is correct.
If this was fixed, Option A would be correct since the Comparator sorts in ascending order.