About Question enthuware.ocpjp.ii.v11.2.3339 :
Posted: Thu Jan 07, 2021 8:28 am
Given the code...
This will actually not compile because unknown number variable
The given variable must be changed to x like below :
Code: Select all
Stream<Integer> sin = Stream.of(1, 2, 3 );
Consumer<Integer> c1 = System.out::print;
Consumer<Integer> c2 = x->{ System.out.println(" * "+number+" = "+x*number); };
INSERT CODE HERE
The given variable must be changed to x like below :
Code: Select all
public static void main(String[] args) throws IOException {
Stream<Integer> sin = Stream.of(1, 2, 3 );
Consumer<Integer> c1 = System.out::print;
Consumer<Integer> c2 = x->{ System.out.println(" * "+x+" = "+x*x); };
sin.forEach(c1.andThen(c2));
}