On page 47, we find the code for compare/fpij/IterateString.java
str.chars()
.mapToObj(ch -> Character.valueOf((char)ch))
.forEach(System.out::println);
This can be further simplified as per IDE suggestion:
str.chars()
.mapToObj(ch -> (char) ch)
.forEach(System.out::println);
because autoboxing takes care of creating the Character
instances.
We are left with .mapToObj(ch -> (char) ch)
which apparently does nothing (but it does, allocating Character
). It is practically is a compiler instruction to switch types.