Java / Ope / Collection操作 / Stream / 終端処理 / collect / toCollection

Java / Ope / Collection操作 / Stream / 終端処理 / collect / toCollection

普段は toList で ArrayList に結果をまとめることが多いが独自のコレクションクラスにまとめたい場合があるその場合にこれを使う

List<Integer> myList = Stream.of(1, 2, 3, 4, 5).collect(
        Collectors.toCollection(LinkedList::new)
);
java/ope/collection_ope/stream/tarminator/collect/tocollection.txt · 最終更新: 2020-12-31 09:43 by ore