Streams

  1. In Java 8+ you can make a stream of your int array. Call either Arrays.stream or IntStream.of.
  2. Call IntStream#boxed to use boxing conversion from int primitive to Integer objects.
  3. Collect into a list using Stream.collect( Collectors.toList() ). Or more simply in Java 16+, call Stream#toList().

Example:

int[] ints = {1,2,3};
List<Integer> list = Arrays.stream(ints).boxed().collect(Collectors.toList());

In Java 16 and later:

List<Integer> list = Arrays.stream(ints).boxed().toList();
Answer from mikeyreilly on Stack Overflow
๐ŸŒ
ExamClouds
examclouds.com โ€บ home โ€บ java core โ€บ convert int array to list and back in java
Convert int Array to List<Integer> and ArrayList in Java
September 16, 2026 - How do I convert an int array to an ArrayList specifically? Use Arrays.stream(arr).boxed().collect(Collectors.toCollection(ArrayList::new)), or wrap an existing collection with new ArrayList<>(list).
People also ask

How do I convert Integer[] to int[] and back?
From Integer[] to int[]: Arrays.stream(boxed).mapToInt(Integer::intValue).toArray(). The other way round: Arrays.stream(primitives).boxed().toArray(Integer[]::new). A plain assignment between the two array types does not compile, because they are unrelated types.
๐ŸŒ
examclouds.com
examclouds.com โ€บ home โ€บ java core โ€บ convert int array to list and back in java
Convert int Array to List<Integer> and ArrayList in Java
How do I convert an int array to an ArrayList specifically?
Use Arrays.stream(arr).boxed().collect(Collectors.toCollection(ArrayList::new)), or wrap an existing collection with new ArrayList&lt;&gt;(list). Both give you a mutable ArrayList that accepts add() and remove().
๐ŸŒ
examclouds.com
examclouds.com โ€บ home โ€บ java core โ€บ convert int array to list and back in java
Convert int Array to List<Integer> and ArrayList in Java
Why does Arrays.asList(intArray) return a list with one element?
The method is declared as Arrays.asList(T... a), and the type parameter T can only be a reference type. An int[] is an object itself, so it is passed as a single argument and the result is a List of size 1. To get a List, use Arrays.stream(arr).boxed().
๐ŸŒ
examclouds.com
examclouds.com โ€บ home โ€บ java core โ€บ convert int array to list and back in java
Convert int Array to List<Integer> and ArrayList in Java
๐ŸŒ
Ducmanhphan
ducmanhphan.github.io โ€บ 2022-04-17-how-to-convert-int-to-list-integer
How to convert int[] to List of Integer
Using the improved version of Arrays.stream() in Java 16+. List<Integer> data = Arrays.stream(rawData) .boxed() .toList();
๐ŸŒ
Techie Delight
techiedelight.com โ€บ home โ€บ java โ€บ convert int array to list of integer in java
Convert int array to List of Integer in Java | Techie Delight
July 7, 2026 - A naive solution is to create a list of Integer and use a regular for-loop to add elements from a primitive integer array. ... We can use Java 8 Stream to convert a primitive integer array to an Integer list.
๐ŸŒ
DEV Community
dev.to โ€บ pfilaretov42 โ€บ tiny-how-the-conversion-of-int-to-list-can-be-buggy-21oa
[Tiny] How the conversion of int[] to List<Integer> can be buggy? - DEV Community
June 1, 2023 - The reason is that Arrays.asList(array) does not box int to Integer and creates a List of <int[]>, not a List of Integer as we wanted it to. ... Integer[] array = new Integer[]{42, 5, 1, 3, 4}; List<Integer> list = new ArrayList<>(Arrays.asList(array)); System.out.println(list.get(0)); array can be converted to List<Integer> using IntStream with boxing:
๐ŸŒ
W3docs
w3docs.com โ€บ home โ€บ code snippets โ€บ java โ€บ how to convert int[] into list in java?
How to convert int[] into List&lt;Integer&gt; in Java? | W3docs
Finally, you can use the collect() method to collect the elements of the stream into a List<Integer>. ... import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class Main { public static void main(String[] ...
Find elsewhere
๐ŸŒ
Codemia
codemia.io โ€บ home โ€บ knowledge hub โ€บ how to convert int[] into list in java?
How to convert int[] into List<Integer> in Java? | Codemia
January 25, 2025 - For earlier versions of Java or for scenarios where you want to avoid Streams for simplicity or performance reasons, you can use a simple loop to convert an array to a list: ... 1import java.util.ArrayList; 2import java.util.List; 3 4public class ArrayToList { 5 public static void main(String[] args) { 6 int[] array = {1, 2, 3, 4, 5}; 7 List<Integer> list = new ArrayList<>(); 8 for (int value : array) { 9 list.add(value); // Autoboxing converts int to Integer automatically 10 } 11 System.out.println(list); 12 } 13}
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ array-to-arraylist-conversion-in-java
Array to ArrayList Conversion in Java - GeeksforGeeks
July 11, 2025 - This method returns a fixed-size list backed by the specified array, which we can then pass to the constructor of an ArrayList. ... // Java program to illustrate conversion // of an array to an ArrayList import java.util.ArrayList; import java.util.Arrays; public class Geeks { public static void convertUsingAsList(Integer[] arr) { ArrayList<Integer> al = new ArrayList<>(Arrays.asList(arr)); System.out.println(al); } public static void main(String[] args) { Integer[] arr = {1, 2, 3, 4, 5}; convertUsingAsList(arr); } }
๐ŸŒ
Mkyong
mkyong.com โ€บ home โ€บ java โ€บ java โ€“ how to convert a primitive array to list
Java โ€“ How to convert a primitive Array to List | mkyong.com
November 17, 2016 - In Java 8, you can use the Stream APIs to do the boxing and conversion like this : List<Integer> list = Arrays.stream(number).boxed().collect(Collectors.toList()); Full example to convert a primitive Array to a List.
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java list โ€บ convert a list of integers to a list of strings
Convert a List of Integers to a List of Strings | Baeldung
June 9, 2025 - In this short article, weโ€™ve learned three ways to convert List<Integer> to List<String>. If our Java version is 8+, Stream API would be the most straightforward conversion method.
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java array โ€บ converting between an array and a list in java
Converting Between an Array and a List in Java Baeldung
August 6, 2025 - Learn about different ways of converting a List to a Map in Java, using core functionalities and some popular libraries ... @Test public void givenUsingCoreJava_whenListConvertedToArray_thenCorrect() { List<Integer> sourceList = Arrays.asList(0, 1, 2, 3, 4, 5); Integer[] targetArray = sourceList.toArray(new Integer[0]); }
๐ŸŒ
Java67
java67.com โ€บ 2019 โ€บ 03 โ€บ how-to-convert-int-array-to-arraylist-in-java-8-example.html
How to convert int array to ArrayList of Integer in Java 8? [Example/Tutorial] | Java67
In fact, there was no shortcut to convert an int[] to ArrayList<Integer> or long[] to ArrayList<Long> till Java 8. From JDK 8 onwards, you either had to make a utility method or need to use general-purpose Java libraries like Google Guava or Apache Commons to convert an array of primitive values.
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java array โ€บ convert an array of primitives to a list
Convert an Array of Primitives to a List | Baeldung
April 4, 2025 - There is no automatic conversion from an array of primitive types to an array of their boxed reference types (for example from int[] to Integer[]). Letโ€™s start to implement a few solutions to this problem. Since autoboxing works with single primitive elements, a simple solution is to just iterate over the elements of the array and add them to the List one by one:
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ java โ€บ examples โ€บ convert a list to array and vice versa
Java Program to Convert a List to Array and Vice Versa | Vultr Docs
November 25, 2024 - Similar to integers, the String[] array is converted to a List<String> using the Arrays.asList() method. It demonstrates compatibility with different data types. Mastering the conversion between lists and arrays in Java enhances versatility in handling data collections.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ program-to-convert-array-to-list-in-java
Java Program to Convert an Array into a List - GeeksforGeeks
July 11, 2025 - ... import java.util.*; public ... 5, 6, 7, 8}; // Converting array to ArrayList List<Integer> lis = new ArrayList<>(Arrays.asList(arr)); System.out.println("List: " + lis); // Adding a new element to the ArrayList lis.add(9); ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ program-to-convert-list-of-integer-to-list-of-string-in-java
Program to convert List of Integer to List of String in Java - GeeksforGeeks
July 11, 2025 - Convert Stream of Integer to Stream of String. This is done using Stream.map() and passing s -> String.valueOf(s) method as lambda expression. Collect Stream of String into List of String.