How do I convert a Java 8 IntStream to a List?

Eric Wilson :

I'm looking at the docs for the IntStream, and I see an toArray method, but no way to go directly to a List<Integer>

Surely there is a way to convert a Stream to a List?

Ian Roberts :


IntStream::boxed turns an IntStream into a Stream<Integer>, which you can then collect into a List:


The boxed method converts the int primitive values of an IntStream into a stream of Integer objects. The word "boxing" names the intInteger conversion process. See Oracle Tutorial.

Collected from the Internet

Please contact javaer1[email protected] to delete if infringement.

edited at


Login to comment


How do I determine if a integer in a Java Intstream is of the form 3x+1?

How do i convert a json array object of an object into a java 8 optional list of that object

How do I sort a List of TreeSets with java8 streams

Convert Map<String,List<Person>> to Map<String,List<Employee>>, using Java 8 streams. I did this but how do this without for loop

How do I operate with IntStream?

How to convert IntStream into List<Character>?

How do I convert java.sql.Array to List<MyCustomEnum>?

Java 8: IntStream to Integer[]

How to convert Map to List in Java 8

How do I get an IntStream from a List<Integer>?

How do I convert from List<?> to List<T> in Java using generics?

How do I convert a string to a list of chars?

How do I convert user input into a list?

How do I convert a list of tuples to a dictionary

Using Java 8 streams how do I convert Map<String, List<Something>> to Map<String, Integer>?

How to convert a list of objects into a map in Java 8?

How do I convert a list/dictionary into a Dataframe?

How do I convert List<String[]> values from UTF-8 to String?

How do I convert a list of integers into bytes?

How do I convert int(input) into a list

How to convert List to varargs object in Java 8

How do I convert a List<Employee> to Map<Employee, List<String>> using java8?

How do I convert list into dictionary in Python?

how to convert list to map by java8?

How to convert IntStream to List in java?

How do I convert an array or a list into a hashref?

How do I convert a list into a matrix in KDB?

How can I convert List of LinkedHashMap to List of Custom Object using Java 8

How do I convert a Map in LIst to a Map?