What you are doing may be the simplest way, provided your stream stays sequential—otherwise you will have to put a call to sequential() before forEach.

The reason the call to sequential() is necessary is that the code as it stands (forEach(targetLongList::add)) would be racy if the stream was parallel. Even then, it will not achieve the effect intended, as forEach is explicitly nondeterministic—even in a sequential stream the order of element processing is not guaranteed. You would have to use forEachOrdered to ensure correct ordering. The intention of the Stream API designers is that you will use collector in this situation, as below:

targetLongList = sourceLongList.stream()
    .filter(l -> l > 100)
    .collect(Collectors.toList());
Answer from Maurice Naftalin on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java streams › collecting stream elements into a list in java
Collecting Stream Elements into a List in Java | Baeldung
December 3, 2025 - However, there have been change requests for a method to get a List directly from a Stream instance. With the Java 16 release, we can now invoke toList(), a new method directly on the Stream, to get the List.
Discussions

Why would the JDK Stream.toList() instantiate multiple lists?

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions

  • You include any and all error messages in full

  • You ask clear questions

  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

    Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

More on reddit.com
🌐 r/javahelp
3
2
August 23, 2023
Stream.toList() cannot be assigned to List of interface
I believe you can do .collect(Collectors.toList()) and it should infer to the type I believe. More on reddit.com
🌐 r/javahelp
12
1
June 7, 2021
Converting Stream to a List of user defined object
Your bottom code looks correct to me, you probably just need to import the Collectors class correctly. More on reddit.com
🌐 r/javahelp
2
1
April 23, 2021
Stream.toList() and other converter methods I’ve wanted since Java 2
Brian Goetz gave an in depth and thoughtful response to an email by the author on the same topic: https://mail.openjdk.java.net/pipermail/core-libs-dev/2021-February/073948.html More on reddit.com
🌐 r/java
20
28
February 9, 2021
🌐
HowToDoInJava
howtodoinjava.com › home › java 8 › java collect stream to list (with examples)
Java Collect Stream to List (with Examples)
April 29, 2024 - Stream<String> tokenStream = Stream.of("A", "B", "C", "D"); List<String> tokenList = tokenStream.toList(); This method has been added in Java 10.
🌐
Stackify
stackify.com › streams-guide-java-8
A Guide to Java Streams: In-Depth Tutorial With Examples
September 4, 2024 - The strategy for this operation is provided via the Collector interface implementation. In the example above, we used the toList collector to collect all Stream elements into a List instance.
🌐
Mkyong
mkyong.com › home › java8 › java 8 – convert a stream to list
Java 8 - Convert a Stream to List - Mkyong.com
March 18, 2019 - package com.mkyong.java8; import ...tem.out::println); } } output · java python node · Yet another example, filter a number 3 and convert it to a List....
🌐
Blogger
javarevisited.blogspot.com › 2015 › 03 › 5-ways-to-convert-java-8-stream-to-list.html
5 ways to Convert Java 8 Stream to List - Example, Tutorial
October 6, 2021 - ... This is actually a generalization ... ArrayList, LinkedList, or any other List. In this example, we are collecting Stream elements into ArrayList....
🌐
GeeksforGeeks
geeksforgeeks.org › java › program-to-convert-list-to-stream-in-java
Program to Convert List to Stream in Java - GeeksforGeeks
July 11, 2025 - In this program, the interface is overridden to match the strings that start with "G". Convert Stream into List using List.stream() method. Filter the obtained stream using the defined predicate condition · The required Stream has been obtained.
Find elsewhere
🌐
Java67
java67.com › 2020 › 04 › how-to-get-list-or-set-from-stream-in-java8.html
How to Convert Stream to List, Set, and Collection in Java 8? Example Tutorial | Java67
In the past, I have shared 10 examples ... I'll show you a simple example of using Collectors and Stream.collect() method to convert Stream to List and Set in Java 8....
🌐
Stack Abuse
stackabuse.com › java-8-streams-convert-a-stream-to-list
Guide to Java 8 Collectors: Definitive Guide to toList()
November 19, 2024 - Though, you're not limited to just collecting a stream into a list - this is where the collectingAndThen() method comes into play. Earlier on we consulted the official documentation and, it stated that collectors have the capacity of: …optionally transforming the accumulated result into a final representation after all input elements have been processed. The accumulated result in CollectorsBloodBank, for example, is represented by Collectors.toList().
🌐
JRebel
jrebel.com › blog › java-streams-in-java-8
Using Java Streams in Java 8 and Beyond | JRebel by Perforce
In the example below, the Java stream is used as a fancy iterator: List numbers = Arrays.asList(1, 2, 3, 4); List result = numbers.stream() .filter(e -> (e % 2) == 0) .map(e -> e * 2) .collect(toList());
🌐
Medium
medium.com › @AlexanderObregon › javas-collectors-tolist-method-explained-0e90e5d90dcb
Java’s Collectors.toList() Method Explained | Medium
August 23, 2024 - Often, filtering and mapping are used together in a stream pipeline to achieve more complex data transformations. For example, let’s say you have a list of product prices in various currencies, and you want to filter out prices below a certain threshold and convert the remaining prices to a different currency: import java.util.List; import java.util.stream.Collectors; import java.util.stream.DoubleStream; public class PriceConversionExample { public static void main(String[] args) { double conversionRate = 0.85; // Conversion rate to another currency List<Double> convertedPrices = DoubleStream.of(100.0, 50.0, 250.0, 75.0, 300.0) .filter(price -> price > 100.0) .map(price -> price * conversionRate) .boxed() .collect(Collectors.toList()); System.out.println(convertedPrices); // Output: [212.5, 255.0] } }
🌐
Java67
java67.com › 2016 › 03 › how-to-get-arraylist-from-stream-in-java8-example.html
How to Convert Stream to ArrayList in Java 8 - Collectors.toCollection() Example | Java67
All you need to do is first get the stream from List by calling stream() method, then call the filter() method to create a new Stream of filtered values and finally call the Collectors.toCollection(ArrayList::new) to collect those elements into ...
🌐
Medium
neesri.medium.com › how-to-convert-a-stream-to-list-set-map-and-different-types-of-collections-1902c849e34a
How to Convert a Stream to List, Set, Map and different types of collections. | by A cup of JAVA coffee with NeeSri | Medium
July 25, 2025 - So, if the stream was generated from a list of elements like [1, 2, 3, 4], the resulting list will also maintain the order [1, 2, 3, 4]. This is one of the key properties of a List in Java — it preserves the order of insertion.
🌐
GeeksforGeeks
geeksforgeeks.org › java › stream-in-java
Stream In Java - GeeksforGeeks
Below is the syntax given for declaring a Java Stream. ... A Stream is not a data structure; it just takes input from Collections, Arrays or I/O channels. Streams do not modify the original data; they only produce results using their methods. Intermediate operations (like filter, map, etc.) are lazy and return another Stream, so you can chain them together.
Published   3 weeks ago
🌐
Winterbe
winterbe.com › posts › 2014 › 07 › 31 › java8-stream-tutorial-examples
Java 8 Stream Tutorial - winterbe
A stream represents a sequence of elements and supports different kind of operations to perform computations upon those elements: List<String> myList = Arrays.asList("a1", "a2", "b1", "c2", "c1"); myList .stream() .filter(s -> s.startsWith("c")) .map(String::toUpperCase) .sorted() ...
🌐
Baeldung
baeldung.com › home › java › java streams › the java stream api tutorial
The Java Stream API Tutorial | Baeldung
October 5, 2023 - So to make the previous code work properly, some changes should be made: List<String> elements = Stream.of("a", "b", "c").filter(element -> element.contains("b")) .collect(Collectors.toList()); Optional<String> anyElement = elements.stream(...
🌐
Oracle
oracle.com › java › technical details
Processing Data with Java SE 8 Streams, Part 1
However, notice the use of lambda expressions (for example, t-> t.getCategory() == Transaction.GROCERY) and method references (for example, Transaction::getId), which you should be familiar with by now. (To brush up on lambda expressions, refer to previous Java Magazine articles and other resources listed at the end of this article.) For now, you can see a stream as an abstraction for expressing efficient, SQL-like operations on a collection of data.
🌐
How to do in Java
howtodoinjava.com › home › java streams › java stream api: real-world examples for beginners
Java Stream API: Real-world Examples for Beginners
September 19, 2023 - In the given example, first, we create a stream on integers 1 to 10. Then we process the stream elements to find all even numbers. At last, we are collecting all even numbers into a List.
🌐
javathinking
javathinking.com › blog › retrieving-a-list-from-a-java-util-stream-stream-in-java-8
Java 8 Stream: How to Retrieve a List Concisely (No More forEach! The Collectors Method You Need) — javathinking.com
For example, Collectors.groupingBy uses a downstream collector to accumulate values per group—often toList() or toUnmodifiableList(). Suppose you have a list of Person objects and want to group them by age: import java.util.List; import java.util.Map; import java.util.stream.Collectors; class Person { private String name; private int age; public Person(String name, int age) { this.name = name; this.age = age; } public int getAge() { return age; } public String getName() { return name; } @Override public String toString() { return name; } } public class GroupingExample { public static void ma