IntStream::boxed

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

theIntStream.boxed().collect(Collectors.toList())

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.

Java 16 and later

Java 16 brought the shorter toList method. Produces an unmodifiable list. Discussed here.

theIntStream.boxed().toList() 
Answer from Ian Roberts on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › stream › IntStream.html
IntStream (Java Platform SE 8 )
March 16, 2026 - Returns an infinite sequential ordered IntStream produced by iterative application of a function f to an initial element seed, producing a Stream consisting of seed, f(seed), f(f(seed)), etc.
🌐
Tabnine
tabnine.com › home page › code › java › java.util.stream.intstream
java.util.stream.IntStream.collect java code examples | Tabnine
@Override public <R> R collect(Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R, R> combiner) { return finallyClose(() -> stream().collect(supplier, accumulator, combiner)); } ... @Test public void testShuffled() { List<Integer> list = IntStream.range(0, INPUT_SIZE).collect(ArrayList::new, ArrayList::add, ArrayList::addAll); Collections.shuffle(list); test(list.stream().mapToInt(Integer::intValue), list.stream().mapToInt(Integer::intValue).mapToObj(key -> Integer.toString(key * 2)), MAX_ELEMENTS_COMPARATOR, IntStream.range(INPUT_SIZE - OUTPUT_SIZE, INPUT_SIZE).mapToObj(key ->
🌐
Baeldung
baeldung.com › home › java › java streams › java intstream conversions
Java IntStream Conversions | Baeldung
January 8, 2024 - In this example, we make use of the method range. The most notorious part here is using the method boxed, that, as its name points out, will box all the int elements in the IntStream and will return a Stream<Integer>. Finally, we can use a collector to get a list of integers.
🌐
HowToDoInJava
howtodoinjava.com › home › java 8 › collecting stream of primitives into collection or array
Collecting Stream of Primitives into Collection or Array
March 14, 2022 - //Primitive Stream -> List List<Integer> listOfIntegers = IntStream.of(1,2,3,4,5) .boxed() .collect(Collectors.toList()); List<Long> listOfLongs = LongStream.of(1,2,3,4,5) .boxed() .collect(Collectors.toList()); List<Double> listOfDoubles = DoubleStream.of(1.0,2.0,3.0,4.0,5.0) .boxed() .collect(Collectors.toList());
🌐
Dirask
dirask.com › posts › Java-8-convert-Int-Stream-to-list-with-Collectors-error-fix-v10EaD
Java 8 - convert Int Stream to list with Collectors - error fix
// IntStream.of(1, 2, 3, 4, 5) // .collect(Collectors.toList()); // FIX: List<Integer> collect = IntStream.of(1, 2, 3, 4, 5) .boxed() // <-- this line fix the problem .collect(Collectors.toList()); // [1, 2, 3, 4, 5] System.out.println(collect);
Find elsewhere
🌐
HowToDoInJava
howtodoinjava.com › home › java 8 › guide to intstream in java
Guide to IntStream in Java - HowToDoInJava
March 4, 2022 - Using boxed() method of IntStream, we can get a stream of wrapper objects which can be collected by Collectors methods.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-stream-collect-method-examples
Java Stream collect() Method Examples | DigitalOcean
August 3, 2022 - Java Stream collect() performs a mutable reduction operation on the elements of the stream.
🌐
Medium
medium.com › javarevisited › how-to-collect-a-java-stream-into-a-primitive-collection-0a90e246c16e
How to collect a Java Stream into a primitive Collection | Javarevisited
June 6, 2024 - The Three Musketeer version of collect can be used to create primitive collections in Eclipse Collections as we can see in the following examples. @Test public void intStreamToIntList() { IntStream intStream = IntStream.of(1, 2, 3, 4, 5); // Three Musketeer collect IntList ints = intStream.collect( IntLists.mutable::empty, // Supplier MutableIntList::add, // ObjIntConsumer MutableIntList::addAll); // BiConsumer IntList expected = IntLists.mutable.of(1, 2, 3, 4, 5); Assertions.assertEquals(expected, ints); }
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Java 8 - Convert IntStream To List and Other - Java Code Geeks
November 27, 2021 - In java 8 API, IntStream class has boxed() method. boxed() method converts the primitive int values into a stream of integer objects. Once we get the Stream<Integer> instance then we can convert it to the List or Set or Map or any collection.
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Java 8 IntStream With Working Examples - Java Code Geeks
January 3, 2022 - Use collect() method to collect the output of IntStream into List or Set.
🌐
Java Guides
javaguides.net › 2024 › 07 › java-intstream-collect-method.html
Java IntStream collect() Method
July 3, 2024 - This example shows how to use collect() with a custom collector to accumulate elements into a StringBuilder. import java.util.stream.IntStream; public class CustomCollectorExample { public static void main(String[] args) { IntStream intStream = IntStream.of(1, 2, 3, 4, 5); // Collect the elements into a StringBuilder StringBuilder stringBuilder = intStream.collect( StringBuilder::new, // Supplier (sb, i) -> sb.append(i).append(", "), // Accumulator StringBuilder::append // Combiner ); // Print the StringBuilder System.out.println(stringBuilder); } }
🌐
HowToDoInJava
howtodoinjava.com › home › java 8 › java collect stream to list (with examples)
Java Collect Stream to List (with Examples)
April 29, 2024 - Stream<Employee> employeeStream = Stream.of( new Employee(1, "A", 100), new Employee(2, "B", 200), new Employee(3, "C", 300), new Employee(4, "D", 400), new Employee(5, "E", 500), new Employee(6, "F", 600)); List<Employee> employeeList = employeeStream .filter(e -> e.getSalary() < 400) .collect(Collectors.toList()); To convert an infinite stream into a list, we must limit the stream to a finite number of elements. Given example will work in the case of a stream of primitives. IntStream infiniteNumberStream = IntStream.iterate(1, i -> i+1); List<Integer> integerlist = infiniteNumberStream.limit(10) .boxed() .collect(Collectors.toList());
🌐
Guava
guava.dev › releases › 23.0 › api › docs › com › google › common › collect › Streams.html
Streams (Guava: Google Core Libraries for Java 23.0 API)
Returns an IntStream containing the elements of the first stream, followed by the elements of the second stream, and so on.
🌐
Oracle
docs.oracle.com › en › java › javase › 26 › docs › api › java.base › java › util › stream › IntStream.html
IntStream (Java SE 26 & JDK 26)
March 16, 2026 - <R> R · collect · (Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R, R> combiner) Performs a mutable reduction operation on the elements of this stream. static IntStream · concat · (IntStream a, IntStream b) Creates a lazily concatenated stream whose elements are all the ...
🌐
Tabnine
tabnine.com › home page › code › java › java.util.stream.intstream
java.util.stream.IntStream.range java code examples | Tabnine
private String columnDefinitions(List<DataTypeTest.Input<?>> inputs) { List<String> columnTypeDefinitions = inputs.stream() .map(DataTypeTest.Input::getInsertType) .collect(toList()); Stream<String> columnDefinitions = range(0, columnTypeDefinitions.size()) .mapToObj(i -> format("col_%d %s", i, columnTypeDefinitions.get(i))); return Joiner.on(",\n").join(columnDefinitions.iterator()); } } ... protected String formatInvokeError(String text, Object[] args) { String formattedArgs = IntStream.range(0, args.length) .mapToObj(i -> (args[i] != null ?
🌐
Medium
neesri.medium.com › primitive-type-in-stream-java-8-fb587f5c1e5b
Mastering IntStream in Java 8. In Java 8 and later versions, the… | by A cup of JAVA coffee with NeeSri | Medium
July 20, 2025 - Current Design If you see Stream Interface that provides lot of great features to process elements in a collection, it extends from BaseStream interface. BaseStream Interface is also extended by IntStream, DoubleStream and LongStream Interface.