Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
5
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

@HMMNRST

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()) ※コピー不可、データソースから組み直すこと

ドキュメント:

その他:

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
5
Help us understand the problem. What are the problem?