Help us understand the problem. What is going on with this article?

Javaの配列・リスト・ストリーム相互変換一覧表

インスタンスメソッドで直接変換できたり、クラスメソッドで用意されていたり、もっと複雑なことが必要だったり、ややこしかったので纏めておく。

from \ to T[] List<T> Stream<T>
T[] array Arrays.copyOf(array, array.length) Arrays.asList(array) (固定長・配列と連動) Arrays.stream(array)

Stream.of(array)
List<T> list list.toArray(new T[0]) new ArrayList<>(list)

Collections.unmodifiableList(list) (変更不可)
list.stream()

list.parallelStream() (並列)
Stream<T> stream stream.toArray(T[]::new) stream.collect(Collectors.toList()) ※コピー不可、データソースから組み直すこと

ドキュメント:

その他:

HMMNRST
計算資源は有限。効率よく使って、浮いた分で思い切り遊びたい。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした