About Question enthuware.ocpjp.v8.2.1847 :
Moderator: admin
-
- Posts: 15
- Joined: Fri May 15, 2015 12:06 am
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1847 :
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.
-
- Posts: 4
- Joined: Wed Jul 10, 2019 11:41 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1847 :
as both collect and forEach are terminal operations, doesn't the code result in compilation error?
-
- Site Admin
- Posts: 10404
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1847 :
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.
You might want to try compiling and running the code.
Who is online
Users browsing this forum: Bing [Bot] and 11 guests