Page 1 of 1

Re: About Question enthuware.ocpjp.v8.2.1847 :

Posted: Fri Oct 16, 2015 4:27 pm
by Ad9999
So basically if you wanted Collectors.toMap to ignore duplicate key entries you'd pass in something like (a,b) -> a for the BinaryOperator argument.

Re: About Question enthuware.ocpjp.v8.2.1847 :

Posted: Sat Sep 21, 2019 5:02 pm
by sreeharshitha
as both collect and forEach are terminal operations, doesn't the code result in compilation error?

Re: About Question enthuware.ocpjp.v8.2.1847 :

Posted: Sat Sep 21, 2019 11:22 pm
by admin
The code is not calling two terminal operations on the same stream. The call to collect returns a Map and forEach is called on that Map.
You might want to try compiling and running the code.