June 2018
Beginner
722 pages
18h 47m
English
The boxed() intermediate operation converts (boxes) elements of the primitive numeric type to the corresponding wrapper type:
//IntStream.range(1, 3).map(Integer::shortValue) //compile error// .forEach(System.out::print); IntStream.range(1, 3).boxed().map(Integer::shortValue) .forEach(System.out::print); //prints: 12//LongStream.range(1, 3).map(Long::shortValue) //compile error// .forEach(System.out::print); LongStream.range(1, 3).boxed().map(Long::shortValue) .forEach(System.out::print); //prints: 12//DoubleStream.of(1).map(Double::shortValue) //compile error// .forEach(System.out::print); DoubleStream.of(1).boxed().map(Double::shortValue) .forEach(System.out::print); //prints: 1
In the preceding code, we have commented ...
Read now
Unlock full access