IntStream is = IntStream.of(1,2,3);
IntUnaryOperator un = IntUnaryOperator.identity();
is.forEach(s -> un.applyAsInt(s));
forEach method can only take consumer as the argument then how does it compile successfully with applyAsInt man method which returns int?
Can anyone please explain the reason behind this?
Because "s -> un.applyAsInt(s)" is a Consumer