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 int ⬌ Integer 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 OverflowIntStream::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 int ⬌ Integer 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()
You could also use mapToObj() on a Stream, which takes an IntFunction and returns an object-valued Stream consisting of the results of applying the given function to the elements of this stream.
List<Integer> intList = myIntStream.mapToObj(i->i).collect(Collectors.toList());
The primitive streams don't have the same collect method as Stream. You can convert them to a stream of the wrapper type in order to use the collect method that accepts a Collector argument:
List<Integer> list1 = iStream.boxed().collect(Collectors.toList());
IntStream (along with the other primitive streams) does not have a collect(Collector) method. Its collect method is: collect(Supplier,ObjIntConsumer,BiConsumer).
If you want to collect the ints into a List you can do:
List<Integer> list = IntStream.range(0, 10).collect(ArrayList::new, List::add, List::addAll);
Or you can call boxed() to convert the IntStream to a Stream<Integer>:
List<Integer> list = IntStream.range(0, 10).boxed().collect(Collectors.toList());
Both options will box the primitive ints into Integers, so which you want to use is up to you. Personally, I find the second option simpler and clearer.