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
🌐
Delft Stack
delftstack.com › home › howto › java › convert int array to arraylist java
How to Convert Int Array to Arraylist in Java | Delft Stack
February 2, 2024 - For this to work, we first create an array of int elements and use the Arrays class to call the stream() method. But as the items of intArray are of primitive types, we have to use the boxed() to box each primitive to an Integer object.
🌐
GeeksforGeeks
geeksforgeeks.org › java › array-to-arraylist-conversion-in-java
Array to ArrayList Conversion in Java - GeeksforGeeks
July 11, 2025 - Example: Java · // Java program to illustrate conversion // of an array to an ArrayList import java.util.ArrayList; public class Geeks { public static void convertUsingAdd(int[] arr) { ArrayList<Integer> al = new ArrayList<>(); // Manually ...
🌐
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
Here we are passing ArrayList::new which is a constructor reference, which means all elements of Stream will be collected into an ArrayList. See The Complete Java MasterClass to learn more. By far, That was the simplest way to convert an array of primitive data types to a List of wrapper objects like an array of ints to ArrayList of Integers.
🌐
GeeksforGeeks
geeksforgeeks.org › java › arraylist-in-java
ArrayList in Java - GeeksforGeeks
To make it thread-safe, you must wrap it manually using Collections.synchronizedList(). ... import java.util.ArrayList; class Main { public static void main (String[] args) { // Creating an ArrayList ArrayList<Integer> a = new ArrayList<Integer>(); ...
Published   October 6, 2016
🌐
DaniWeb
daniweb.com › programming › software-development › threads › 435424 › integer-array-to-arraylist
java - integer array to arraylist | DaniWeb
When you create an array list, you cannot use primitive data type to create. ArrayList<int> array = new ArrayList<int>(); // <-- compile error!
🌐
W3Schools
w3schools.com › java › java_arraylist.asp
Java ArrayList
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Server Java Syllabus Java Study Plan Java Interview Q&A Java Certificate ... An ArrayList is like a resizable array. It is part of the java.util package and implements the List interface. The difference between a built-in array and an ArrayList in Java, is that the size of an array cannot be modified (if you want to ...
Find elsewhere
🌐
Dot Net Perls
dotnetperls.com › arraylist-integer-java
Java - ArrayList int, Integer Examples - Dot Net Perls
ArrayList<int> test = new ArrayList<>(); } } Exception in thread "main" java.lang.Error: Unresolved compilation problem: Syntax error, insert "Dimensions" to complete ReferenceType at Program.main(Program.java:8) We cannot pass an int array to the Collections.addAll method to add Integers to ...
🌐
CodeGym
codegym.cc › java blog › java collections › arraylist to array conversion in java
How to Convert an Array to ArrayList in Java
January 15, 2025 - An ArrayList gives you that flexibility and the ability to insert and remove nodes as needed. Learning how to convert a Java Array to a List will improve the overall efficiency of your programs and improve their runtimes as well. ... Artem is a programmer-switcher. His first profession was rehabilitation specialist. Previously, he helped people restore their hea ... [Read full bio] ... The code "Integer boltsInventoryArray[] = new Integer{boltsInventory.size()];" needs to be changed to "Integer boltsInventoryArray[] = new Integer[boltsInventory.size()];"
🌐
Coderanch
coderanch.com › t › 464780 › java › ArrayList-Integer
new ArrayList ({1,2,3,4}) (Beginning Java forum at Coderanch)
Something like: List<Integer> a = new ArrayList<Integer>({1,2,3,4}); I do not want to use: a.add(1); a.add(2); .. ... See constructor of arraylist that what is allowed to pass in the constructor. ... There is no constructor in Collection classes which takes an array.
🌐
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 - Let’s start with the plain Java ... a List: @Test public void givenUsingCoreJava_whenArrayConvertedToList_thenCorrect() { Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; List<Integer> targetList = Arrays.asList(sourceArray); } Note that ...
🌐
Lawrence
www2.lawrence.edu › fast › GREGGJ › CMSC150 › 062ArrayLists › ArrayLists.html
Working with ArrayLists
ArrayList<int> C = new ArrayList<int>(); // Illegal - int is not an object type · The workaround for this is that Java provides a class equivalent for every one of the primitive types. For example, there is an Integer class corresponding to the int type and a Double class corresponding to ...
🌐
Delft Stack
delftstack.com › home › howto › java › java arraylist of ints
How to Get ArrayList of Int Array in Java | Delft Stack
February 22, 2025 - Combining the flexibility of ArrayLists with the structure of int arrays provides a powerful toolset for dynamic data manipulation in Java. This approach allows developers to efficiently manage and manipulate arrays in a resizable and convenient manner. The given example demonstrated how to add, access, modify, and remove int arrays, as well as how to get the size of the ArrayList and perform sorting based on the contents of the arrays.
🌐
GeeksforGeeks
geeksforgeeks.org › java › arraylist-array-conversion-java-toarray-methods
ArrayList to Array Conversion in Java : toArray() Methods - GeeksforGeeks
July 23, 2025 - ... // A Java program to demonstrate ... GFG { public static void main(String[] args) { List<Integer> al = new ArrayList<Integer>(); al.add(10); al.add(20); al.add(30); al.add(40); // Error: incompatible types: Object[] // cannot ...
🌐
CodeAhoy
codeahoy.com › java › How-To-Convery-ArrayList-To-Array
ArrayList to Array Conversion in Java | CodeAhoy
March 1, 2020 - To convert ArrayList to array in Java, we can use the toArray(T[] a) method of the ArrayList class. It will return an array containing all of the elements in this list in the proper order (from first to last element.) Here’s a short example to convert an ArrayList of integers, numbersList, ...
🌐
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 - Since autoboxing works with single ... them to the List one by one: int[] input = new int[]{1,2,3,4}; List<Integer> output = new ArrayList<Integer>(); for (int value : input) { output.add(value); } We have solved the problem, but ...
🌐
Studytonight
studytonight.com › forum › how-to-convert-int-into-list-integer-in-java
How to convert int[] into List in Java? - Studytonight
There is no shortcut for converting ... have to make a utility method. int[] ints = {1, 2, 3}; List<Integer> intList = new ArrayList<Integer>(ints.length); for (int i : ints) { intList.add(i); }...