r/javahelp • u/King5lay3r • Dec 12 '20
How do I master Java Streams/Functional Programming?
I was asked to count occurrences of each characters in a String using Java 8 Stream API and although I know basic operations in Streams I would have never guessed the following Collectors.toMap() solution;
Collectors.toMap(k -> Character.valueOf((char) k.intValue()),
v -> 1,
Integer::sum)How, and from where, do I learn such declarative functional programming so that I can know when to use what by looking at the problem?
19
Upvotes
3
u/[deleted] Dec 12 '20
This book helped me a lot.