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
🌐
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
If you don't want to collect but just want to print, you can also use the forEach() method to print all elements of Stream in Java 8. You'll see a couple of examples to understand the concept better in this article. But when you use toList() method there are no guarantees on the type, mutability, serializability, or thread-safety of the List returned, that's why if you need an ArrayList, you should use toCollection() method.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › stream › package-summary.html
java.util.stream (Java Platform SE 8 )
2 weeks ago - As an example of how to transform ... regular expression, and puts the matches in a list. ArrayList<String> results = new ArrayList<>(); stream.filter(s -> pattern.matcher(s).matches()) .forEach(s -> results.add(s)); // Unnecessary use of side-effects!...
🌐
Thospfuller
thospfuller.com › home › tutorials › java code examples › use the java stream api to turn an array into an arraylist!
Use the Java Stream API To Turn An Array Into An ArrayList! | ThosPFuller.com 👍
June 10, 2025 - Note that line #16 means we need to call the boxed method on line 31 yielding performance results that are not limited to the Java Streams API alone. If we change line #16 to use a java.lang.Integer and we remove the call to boxed on line 31 the average time to run this script five times is 8.7 seconds. The gist for the complete example is available on GitHub. Working with the Java ArrayList and Java Streams typically yields more concise and expressive code when it comes to manipulating collections.
🌐
Baeldung
baeldung.com › home › java › java streams › introduction to java streams
Introduction to Java Streams | Baeldung
November 4, 2023 - For example: for (String string : list) { if (string.contains("a")) { return true; } } This code can be changed just with one line of Java 8 code: boolean isExist = list.stream().anyMatch(element -> element.contains("a")); The filter() method ...
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-get-arraylist-from-stream-in-java-8
How to Get ArrayList from Stream in Java 8? - GeeksforGeeks
July 17, 2024 - This Java program demonstrates converting a Stream to an ArrayList using the Collectors.toList method.
🌐
TutorialsPoint
tutorialspoint.com › streams-on-arrays-in-java-8
Streams on Arrays in Java 8
Stream method of array class introduced in Java 8. Let us see an example wherein we are counting empty strings, eliminating empty strings, getting a list of square of distinct numbers, displaying random numbers, etc − · import java.util.ArrayList; import java.util.Arrays; import ...
Find elsewhere
🌐
Java67
java67.com › 2017 › 04 › how-to-convert-java-8-stream-to-array-and-list-in-java.html
How to convert Java 8 Stream to Array and ArrayList in Java? Example Tutorial | Java67
Book[] books = library.stream() .filter(b -> p.getTopic() == FICTION) .toArray(Book[]::new); You can see that this example is even more elegant, classic, and easy to understand than the previous example.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › stream › Stream.html
Stream (Java Platform SE 8 )
2 weeks ago - R result = supplier.get(); for (T element : this stream) accumulator.accept(result, element); return result; Like reduce(Object, BinaryOperator), collect operations can be parallelized without requiring additional synchronization. This is a terminal operation.
🌐
GeeksforGeeks
geeksforgeeks.org › java › program-to-convert-list-to-stream-in-java
Program to Convert List to Stream in Java - GeeksforGeeks
July 11, 2025 - // Java Program to convert // List to Stream in Java 8 import java.util.*; import java.util.stream.*; import java.util.function.*; class GFG { public static void main(String args[]) { // Create a stream of integers List<String> list = Arrays.asList("GeeksForGeeks", "A computer portal", "for", "Geeks"); // Print the List System.out.println("List: " + list); // Create the predicate for item starting with G Predicate<String> predicate = new Predicate<String>() { @Override public boolean test(String s) { // filter items that start with "G" return s.startsWith("G"); } }; System.out.println("Stream from List with items"+ " starting with G: "); // Convert List to stream list.stream() .filter(predicate) .forEach(System.out::println); } }
🌐
Winterbe
winterbe.com › posts › 2014 › 07 › 31 › java8-stream-tutorial-examples
Java 8 Stream Tutorial - winterbe
Intermediate operations return a stream so we can chain multiple intermediate operations without using semicolons. Terminal operations are either void or return a non-stream result. In the above example filter, map and sorted are intermediate operations whereas forEach is a terminal operation. For a full list of all available stream operations see the Stream Javadoc.
🌐
JavaMadeSoEasy
javamadesoeasy.com › 2017 › 06 › convert-arraylist-in-streams-in-java-8.html
JavaMadeSoEasy.com (JMSE): Convert ArrayList in Streams in java 8
You are here : Home / Core Java Tutorials / Java 8 tutorial · 1) Program/ Example - Convert ArrayList in Streams in java 8 · Having any doubt? or you you liked the tutorial! Please comment in below section. Please express your love by liking JavaMadeSoEasy.com (JMSE) on facebook, following on google+ or Twitter.
🌐
Pluralsight
pluralsight.com › tech insights & how-to guides › tech guides & tutorials
Java 8 Stream API: Part 2 | Pluralsight
For example, if we want to "reduce" or "collect" all the elements of a stream into a List, use the following algorithm: List<Integer> list = Stream.of(1, 2, 3, 4, 5) .collect( () -> new ArrayList<>(),// Creating the container (l, i) -> l.add(i), ...
🌐
javaspring
javaspring.net › blog › how-to-add-elements-of-a-java8-stream-into-an-existing-list
How to Add Elements of a Java 8 Stream to an Existing ArrayList: One-Liner Solution with Collectors — javaspring.net
In this blog, we’ll explore a clean, one-liner solution using Collectors.toCollection() to add stream elements directly to an existing ArrayList. We’ll break down the problem, explain the solution step-by-step, discuss alternatives, and highlight best practices to avoid pitfalls. Understanding the Problem: Why Not Just Collect to a New List? ... By default, streams are designed to produce new collections via collect(). For example, the code below creates a new list from a stream: import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors;
🌐
Stack Abuse
stackabuse.com › java-8-streams-convert-a-stream-to-list
Guide to Java 8 Collectors: Definitive Guide to toList()
November 19, 2024 - List list = Stream.of("David", "Scott", "Hiram").collect(Collectors.toList()); System.out.println(String.format("Class: %s\nList: %s", list.getClass(), list)); This example is rather simple and just deals with Strings: Class: class java.util.ArrayList List: [David, Scott, Hiram]
🌐
Dot Net Perls
dotnetperls.com › stream-java
Java - Stream Examples - Dot Net Perls
So We must use the stream() directly ... java.util.stream.Stream; public class Program { public static void main(String[] args) { // Create an Integer ArrayList and add three numbers to it....
🌐
Mkyong
mkyong.com › home › java8 › java 8 streams filter examples
Java 8 Streams filter examples - Mkyong.com
April 3, 2017 - In this tutorial, we will show you few Java 8 examples to demonstrate the use of Streams filter(), collect(), findAny() and orElse() 1.1 Before Java 8, filter a List like this : BeforeJava8.java · package com.mkyong.java8; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class BeforeJava8 { public static void main(String[] args) { List<String> lines = Arrays.asList("spring", "node", "mkyong"); List<String> result = getFilterOutput(lines, "mkyong"); for (String temp : result) { System.out.println(temp); //output : spring, node } } private static List<String> getFilterOutput(List<String> lines, String filter) { List<String> result = new ArrayList<>(); for (String line : lines) { if (!"mkyong".equals(line)) { // we dont like mkyong result.add(line); } } return result; } } Output ·
🌐
Medium
medium.com › java-developers › stream-filter-and-collect-list-items-960f53ac3650
Stream, Filter and Collect List Items | by Venkatesh Vinayakarao | Java Developers | Medium
July 17, 2024 - Here is a simple fully working code example which filters a list based on some condition using Stream. import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; public class TryStream { public static void main(String[] ...
🌐
HowToDoInJava
howtodoinjava.com › home › java 8 › java collect stream to list (with examples)
Java Collect Stream to List (with Examples)
April 29, 2024 - The toList() method has been added in Java 16. It is a default method that collects the stream items into an unmodifiable List. The returned list is an implementation of Collections.unmodifiableList(new ArrayList<>(Arrays.asList(stream.toArray()))) where stream represents the underlying Stream of items.