It was complicated because it could be converted directly by the instance method, it was prepared by the class method, and it needed more complicated things, so I will summarize it.
from \ to | T[] |
List<T> |
Stream<T> |
---|---|---|---|
T[] array |
Arrays.copyOf(array, array.length) |
Arrays.asList(array) (Fixed length / interlocking with array) |
Arrays.stream(array) Stream.of(array) |
List<T> list |
list.toArray(new T[0]) |
new ArrayList<>(list) Collections.unmodifiableList(list) (Cannot be changed) |
list.stream() list.parallelStream() (Parallel) |
Stream<T> stream |
stream.toArray(T[]::new) |
stream.collect(Collectors.toList()) |
* Cannot be copied, reassemble from the data source |
document:
Stream # collect ()
Argument generationOthers:
Recommended Posts