June 2018
Beginner
722 pages
18h 47m
English
These two Terminal operations generate an array that contains the stream elements:
Let's look at an example:
List<String> list = List.of("a", "b", "c");Object[] obj = list.stream().toArray();Arrays.stream(obj).forEach(System.out::print); //prints: abcString[] str = list.stream().toArray(String[]::new);Arrays.stream(str).forEach(System.out::print); //prints: abc
The first example is straightforward. It converts elements to an array of the same type. As for the second example, the representation of IntFunction as String[]::new ...
Read now
Unlock full access