Java array / list / stream mutual conversion list

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:

Others:

Recommended Posts

Java array / list / stream mutual conversion list
[Java] List type / Array type conversion
[Java] Conversion from array to List
Java8 list conversion with Stream map
About Java Array List
[Java] array
Java array
Java array
java (array)
Java array
Java array
java array
[Java] Array
Immutable (immutable) List object conversion function in Java8
Java type conversion
java array variable
Try Java 8 Stream
Clone Java List.
[Java] Array notes
Java Stream API
Array / list / map
Studying Java 8 (Stream)
Java Stream termination
[Java] Stream processing
About List [Java]
Java 9 Optional :: stream
[Java] From two Lists to one array list
[Java] How to operate List using Stream API
[java] sort in list
List processing to understand with pictures --java8 stream / javaslang-
Sample code to convert List to List <String> in Java Stream
[Java] Full-width ⇔ half-width conversion
[Java] Stream Collectors notes
[Java] Stream API / map
Mutual conversion of Bitmap / JPEG / byte array on Android
Java8 Stream API practice
[Java ~ Array ~] Study memo 4
Java8 Stream reduction operation
Mutual conversion between Java objects and JSON using Moshi
[Memo] Java Linked List
Java8 Stream Rough Summary
Endian conversion with JAVA
[Java] Date type conversion
[Java, stream] Sort object list in Japanese by property name
[Java] ArrayList → Should I specify the size in array conversion?
List processing to understand with pictures --java8 stream / javaslang --bonus
[Java8] Sort int type array in descending order using stream
For Java beginners: List, Map, Iterator / Array ... How to convert?
Generate Stream from an array of primitive types in Java
[Java11] Stream Summary -Advantages of Stream-
Java Stream API cheat sheet
[Java] Precautions for type conversion
[Java] Type conversion speed comparison
Java Stream API in 5 minutes
Java8 stream, lambda expression summary
[Java] Stream API --Stream termination processing
[Java] Stream API --Stream intermediate processing
Java Stream cannot be reused.
[Java] List OS-dependent standard libraries
Java Development Basics ~ Exercise (Array) ~
[Java] Introduction to Stream API