Program to Convert List to Stream in Java Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 2 Likes Like Report The List is a child interface of Collection. It is an ordered collection of objects in which duplicate values can be stored. Since List preserves the insertion order, it allows positional access and insertion of elements. List Interface is implemented by ArrayList, LinkedList, Vector and Stack classes. A Stream is a sequence of objects that supports various methods which can be pipelined to produce the desired result. Below are various methods to convert List to Stream in Java: Using List.stream() method: Java List interface provides stream() method which returns a sequential Stream with this collection as its source. Syntax:List.stream()Algorithm: Get the StreamConvert Stream into List using List.stream() method.Return the ListProgram: Java // Java Program to convert // List to Stream in Java 8 import java.util.*; import java.util.stream.*; import java.util.function.Function; class GFG { // Generic function to convert a list to stream private static <T> Stream<T> convertListToStream(List<T> list) { return list.stream(); } 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); // Convert List to stream Stream<String> stream = convertListToStream(list); // Print the Stream System.out.println("Stream from List: " + Arrays.toString(stream.toArray())); } } OutputList: [GeeksForGeeks, A computer portal, for Geeks] Stream from List: [GeeksForGeeks, A computer portal, for Geeks] Filter Stream using a Predicate: The Functional Interface Predicate is defined in the java.util.Function package and can therefore be used as the assignment target for a lambda expression or method reference. It improves manageability of code, helps in unit-testing them separately Algorithm: Get the StreamDefine the Predicate condition by either using pre-defined static methods or by creating a new method by overriding the Predicate interface. 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 conditionThe required Stream has been obtained. Hence Print the filtered elements of the Stream using forEach() method. It can also be returned as required.Program: Java // 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); } } OutputList: [GeeksForGeeks, A computer portal, for, Geeks] Stream from List with items starting with G: GeeksForGeeks Geeks Comment R RishabhPrabhu Follow 2 Improve R RishabhPrabhu Follow 2 Improve Article Tags : Misc Java Java Programs Java - util package java-stream java-list Java-Stream-programs Java-List-Programs +4 More Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings8 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java9 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface4 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java7 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like