If you want to iterate over a list and create a new list with "transformed" objects, you should use the map() function of stream + collect(). In the following example I find all people with the last name "l1" and each person I'm "mapping" to a new Employee instance.

public class Test {

    public static void main(String[] args) {
        List<Person> persons = Arrays.asList(
                new Person("e1", "l1"),
                new Person("e2", "l1"),
                new Person("e3", "l2"),
                new Person("e4", "l2")
        );

        List<Employee> employees = persons.stream()
                .filter(p -> p.getLastName().equals("l1"))
                .map(p -> new Employee(p.getName(), p.getLastName(), 1000))
                .collect(Collectors.toList());

        System.out.println(employees);
    }

}

class Person {

    private String name;
    private String lastName;

    public Person(String name, String lastName) {
        this.name = name;
        this.lastName = lastName;
    }

    // Getter & Setter
}

class Employee extends Person {

    private double salary;

    public Employee(String name, String lastName, double salary) {
        super(name, lastName);
        this.salary = salary;
    }

    // Getter & Setter
}
Answer from Rafael Teles on Stack Overflow
🌐
Stackify
stackify.com › streams-guide-java-8
A Guide to Java Streams in Java 8 - Stackify
September 4, 2024 - From what we discussed so far, a Stream is a stream of object references. However, there are also the IntStream, LongStream, and DoubleStreamwhich are primitive specializations for int, long and double respectively.
Discussions

collections - How can I turn a List of Lists into a List in Java 8? - Stack Overflow
If I have a List>, how can I turn that into a List that contains all the objects in the same iteration order by using the features of Java 8? ... You can use flatMap to flatten the internal lists (after converting them to Streams) into a single Stream, and then collect ... More on stackoverflow.com
🌐 stackoverflow.com
To get list of member from list of objects using Streams java - Stack Overflow
Closed 8 years ago. I have a class with two members and a list of objects of that class . Now I want to extract list of members from the list of objects. ... now I need to retrieve a list of studentName, from list of students. How can this be done with java8 Streams? More on stackoverflow.com
🌐 stackoverflow.com
lambda - Retrieving a List from a java.util.stream.Stream in Java 8 - Stack Overflow
I was playing around with Java 8 lambdas to easily filter collections. But I did not find a concise way to retrieve the result as a new list within the same statement. Here is my most concise appro... More on stackoverflow.com
🌐 stackoverflow.com
Proposal for stream: a (casting) filter by class
It can be "simplified" with .filter(Circle.class::isInstance) and .map(Circle.class::cast) ;) More on reddit.com
🌐 r/java
8
5
October 12, 2016
🌐
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() ...
🌐
GitHub
github.com › alpha74 › Java_streams_Guide
GitHub - alpha74/Java_Streams_Guide: A shortguide to Java 8 streams on Collections · GitHub
Example to combine a list of list of objects into single list using flatMap() List<Integer> list1 = Arrays.asList(1,2); List<Integer> list2 = Arrays.asList(3,4); List<Integer> list3 = Arrays.asList(5,6); List<List<Integer>> listList = Arrays.asList(list1, list2, list3); // Combine all lists into single list List<Integer> combinedList = listList.stream().flatMap(x -> x.stream()).collect(Collectors.toList()); // Output: [1,2,3,4,5,6]
Author   alpha74
🌐
Baeldung
baeldung.com › home › java › java streams › java streams: find items from one list based on values from another list
Java Streams: Find Items From One List Based on Values From Another List | Baeldung
November 30, 2024 - After populating both lists, we create a Stream of Department objects and filter records based on the employeeIdList to exclude.
🌐
Medium
medium.com › @pratik.941 › java-8-streams-tutorial-for-beginners-f76e13df5777
Java 8 Streams Tutorial for Beginners | by Pratik T | Medium
September 9, 2024 - 8. `noneMatch`: Checks if no elements match a given predicate. 9. `findFirst`: Returns the first element of the stream. 10. `findAny`: Returns any element of the stream. ... The `collect` method is used to convert the elements of the stream into a different form, such as a list, set, or map. import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.stream.Collectors; public class CollectExample { public static void main(String[] args) { List<String> words = Arrays.asList("apple", "banana", "cherry", "apple"); // Collect to List List<String> list = words.stream() .collect(Collectors.toList()); System.out.println(list); // Output: [apple, banana, cherry, apple] // Collect to Set Set<String> set = words.stream() .collect(Collectors.toSet()); System.out.println(set); // Output: [apple, banana, cherry] } }
Find elsewhere
🌐
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
You want to prevent accidental modification of the collected list. The list is read-only (e.g., configuration data, API responses). You need thread safety (unmodifiable lists are inherently thread-safe). Use Collectors.toCollection(Supplier<List>) when you need a specific list type (e.g., LinkedList, CopyOnWriteArrayList, or a custom list implementation). The Supplier argument specifies how to create the list: import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; public class ToCollectionExample { public static void main(String[] args) { List<String> words = L
🌐
Stack Abuse
stackabuse.com › java-8-streams-convert-a-stream-to-list
Guide to Java 8 Collectors: Definitive Guide to toList()
November 19, 2024 - In this guide, we'll jump into detail of how Stream collection into Lists works and how you can use pre-defined Collectors and define your own to convert a stream into a list in Java 8.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › stream › Stream.html
Stream (Java Platform SE 8 )
1 month ago - In addition to Stream, which is a stream of object references, there are primitive specializations for IntStream, LongStream, and DoubleStream, all of which are referred to as "streams" and conform to the characteristics and restrictions described here.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-8-stream-tutorial
Java 8 Stream Tutorial - GeeksforGeeks
5 days ago - These Streams are meant to make use of multiple processors or cores available to speed us the processing speed. There are two methods to create parallel streams are mentioned below: ... import java.util.*; import java.util.stream.*; public class ParallelStreamDemo { public static void main(String[] args) { List<Integer> numbers = Arrays.asList(1,2,3,4,5,6,7,8,9); numbers.parallelStream().forEach(n -> System.out.println(n + " " + Thread.currentThread().getName())); } }
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-8-stream
Java 8 Stream - Java Stream | DigitalOcean
August 3, 2022 - I have covered almost all the important parts of the Java 8 Stream API. It’s exciting to use this new API features and let’s see it in action with some java stream examples. There are several ways through which we can create a java stream from array and collections. Let’s look into these with simple examples. We can use Stream.of() to create a stream from similar type of data. For example, we can create Java Stream of integers from a group of int or Integer objects...
🌐
javaspring
javaspring.net › blog › java-stream-collectors-to-list
Java Stream Collectors to List: A Comprehensive Guide — javaspring.net
In this code, we first filter out the even numbers from the stream and then square each of the remaining numbers. Finally, we collect the squared even numbers into a new list. When dealing with a list of custom objects, you can collect a specific field of the objects into a list. import java.util.Arrays; import java.util.List; 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 String getName() { return name; } public int getAge() { return age; } } public class ObjectListToStream { public static void main(String[] args) { List<Person> people = Arrays.asList( new Person("Alice", 25), new Person("Bob", 30), new Person("Charlie", 35) ); List<String> names = people.stream() .map(Person::getName) .collect(Collectors.toList()); System.out.println(names); } }
🌐
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 - Anyway, It seems they did think about this and provided a class called Collector and Collectors to collect the result of stream operations into different containers or Collection classes. Here you will find methods like toList(), which can be used to convert Java 8 Stream to List.
🌐
Baeldung
baeldung.com › home › java › java list › create list of object from another type using java
Create List of Object From Another Type Using Java | Baeldung
March 7, 2025 - Apart from the forEach() method, since Java 8, the Stream API has revolutionized how we manipulate and transform data collections. Next, let’s use the Stream API to solve the problem. We can interpret the problem in this way: filtering the employees whose hobbies cover tennis and transforming these Employee objects into TennisPlayerCandidate objects.
🌐
Baeldung
baeldung.com › home › java › java streams › the java stream api tutorial
The Java Stream API Tutorial | Baeldung
October 5, 2023 - So it is very important to remember that Java 8 streams can’t be reused. This kind of behavior is logical. We designed streams to apply a finite sequence of operations to the source of elements in a functional style, not to store elements. 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().findAny(); Optional<String> firstElement = elements.stream().findFirst();