You can use the following instruction:

new ArrayList<>(Arrays.asList(array));
Answer from Tom on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › conversion-of-array-to-arraylist-in-java
Conversion of Array To ArrayList in Java - GeeksforGeeks
July 23, 2025 - Returns a fixed-size list backed by the specified array. The returned list is serializable and implements RandomAccess. Since returned List is fixed-size therefore we can't add more element in it, but we can replace existing element with new ...
Discussions

Convert list to array in Java - Stack Overflow
How can I convert a List to an Array in Java? Check the code below: ArrayList tiendas; List tiendasList; tiendas = new ArrayList (); Resources res = this. More on stackoverflow.com
🌐 stackoverflow.com
List vs Array vs ArrayList
These are three different things: Array - a very basic data structure. It has a fixed, predetermined size that must be known at the time of creating (instantiating) the array. Think of it as a sorting box with several slots. Here, you have .length - without parentheses as it is a property, not a method List - an interface (not a class) that defines certain behavior. It cannot be instantiated on its own. ArrayList - a concrete class that implements the List interface. When you see a declaration like List data = new ArrayList<>(); there are several things going on: Listprogramming against the interface - here, the interface List is used as data type - this is good practice as it allows you to at any time change the internal representation of the List - e.g. from ArrayList to LinkedList if you figure out that the other better suits your needs. this is a data type identifier. It limits the type of elements that can be stored in the list. Here, only String objects are allowed. If you were to omit this, the list would store Object (the ancestor of all Java classes) and descendant instances (i.e. Object and any subclass of it). data - just the variable name new - the keyword to create a new Object Instance ArrayList<>() - the constructor call. Here, the constructor without parameters of the ArrayList class is called. The diamond operator <> is used to infer (take) the data type for the ArrayList from the variable type (here String). So, the whole is: we create a new variable of type List that can only accept String elements and ist internally represented as ArrayList. More on reddit.com
🌐 r/javahelp
15
7
September 12, 2023
Java: Is Arraylist better than Arrays?
The biggest difference is that you can add to and remove from a list, whereas arrays have a fixed size. More on reddit.com
🌐 r/learnprogramming
28
19
June 23, 2024
Converting an array to an array list?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
6
2
July 24, 2021
🌐
Sentry
sentry.io › sentry answers › java › create arraylist from array in java
Create ArrayList from array in Java | Sentry
October 21, 2022 - The easiest way to convert to an ArrayList is to use the built-in method in the Java Arrays library: Arrays.asList(array). This method will take in a standard array and wrap it in the AbstractList class, exposing all the methods available to ...
🌐
W3Schools
w3schools.com › java › java_arraylist.asp
Java ArrayList
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 add or remove elements to/from an array, you have to create a new one).
🌐
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 solution for converting the array to a List: @Test public void givenUsingCoreJava_whenArrayConvertedToList_thenCorrect() { Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 }; List<Integer> targetList = Arrays.asList(sourceArray); } Note that this is a fixed-sized list that will still be backed by the array. If we want a standard ArrayList, we can simply instantiate one:
🌐
GeeksforGeeks
geeksforgeeks.org › java › array-to-arraylist-conversion-in-java
Array to ArrayList Conversion in Java - GeeksforGeeks
July 11, 2025 - The Arrays.stream() methods creates a stream from the array and the Collectors.toList() collects the stream elements into a list. ... // Java program to illustrate conversion // of an array to an ArrayList import java.util.ArrayList; import ...
Find elsewhere
🌐
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 - Integer boltsInventoryArray[] = new Integer{boltsInventory.size()]; // this ensures the newly created array is of the same size as the ArrayList boltsInventoryArray = boltsInventory.toArray(boltsInventoryArray); When you change a list to array in Java like this, you are creating a deep copy. That is, all references to the Array are different from the references to the ArrayList.
🌐
LabEx
labex.io › tutorials › java-create-arraylist-from-array-117403
Create ArrayList From Array in Java | LabEx
ArrayList<String> courseList2 = ... ArrayList on separate lines. We can also create an ArrayList from an array using the Collections.addAll() method....
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › ArrayList.html
ArrayList (Java Platform SE 8 )
1 week ago - Java™ Platform Standard Ed. 8 ... public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, Serializable · Resizable-array implementation of the List interface. Implements all optional list operations, and permits all elements, including null.
Top answer
1 of 11
1518

Either:

Foo[] array = list.toArray(new Foo[0]);

or:

Foo[] array = new Foo[list.size()];
list.toArray(array); // fill the array

Note that this works only for arrays of reference types. For arrays of primitive types, use the traditional way:

List<Integer> list = ...;
int[] array = new int[list.size()];
for(int i = 0; i < list.size(); i++) array[i] = list.get(i);

Update:

It is recommended now to use list.toArray(new Foo[0]);, not list.toArray(new Foo[list.size()]);.

From JetBrains Intellij Idea inspection:

There are two styles to convert a collection to an array: either using a pre-sized array (like c.toArray(new String[c.size()])) or using an empty array (like c.toArray(new String[0]).

In older Java versions using pre-sized array was recommended, as the reflection call which is necessary to create an array of proper size was quite slow. However since late updates of OpenJDK 6 this call was intrinsified, making the performance of the empty array version the same and sometimes even better, compared to the pre-sized version. Also passing pre-sized array is dangerous for a concurrent or synchronized collection as a data race is possible between the size and toArray call which may result in extra nulls at the end of the array, if the collection was concurrently shrunk during the operation.

This inspection allows to follow the uniform style: either using an empty array (which is recommended in modern Java) or using a pre-sized array (which might be faster in older Java versions or non-HotSpot based JVMs).

2 of 11
409

An alternative in Java 8:

String[] strings = list.stream().toArray(String[]::new);

Since Java 11:

String[] strings = list.toArray(String[]::new);
🌐
W3Schools
w3schools.com › java › ref_arraylist_toarray.asp
Java ArrayList toArray() Method
If the array in the argument is large enough to contain all of the list items then this method will return the argument itself after writing the list items into it. ... T refers to the data type of items in the list. ... import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<String> cars = new ArrayList<String>(); cars.add("Volvo"); cars.add("BMW"); cars.add("Ford"); cars.add("Mazda"); String[] carsArray = new String[4]; carsArray = cars.toArray(carsArray); for(String item : carsArray) { System.out.println(item); } } }
🌐
Codecademy
codecademy.com › docs › java › arraylist › .toarray()
Java | ArrayList | .toArray() | Codecademy
January 5, 2024 - The .toArray() method of the ArrayList class is a common method in Java that converts an ArrayList into an array and returns the newly created array. The returned array contains all the elements in the ArrayList in the correct order.
🌐
Board Infinity
boardinfinity.com › blog › how-to-convert-arraylist-to-array-in-java
Convert ArrayList to Array in Java | Board Infinity
December 9, 2022 - This tutorial will teach you how to convert an ArrayList to an Array in Java using different methods and code examples.
🌐
GeeksforGeeks
geeksforgeeks.org › java › array-of-arraylist-in-java
Array of ArrayList in Java - GeeksforGeeks
July 11, 2025 - // Java code to demonstrate the concept of // array of ArrayList import java.util.*; public class Arraylist { public static void main(String[] args) { int n = 5; // Here al is an array of arraylist having // n number of rows.The number of columns on // each row depends on the user.
🌐
Reddit
reddit.com › r/javahelp › list vs array vs arraylist
r/javahelp on Reddit: List vs Array vs ArrayList
September 12, 2023 -

Coming from Python, this whole Java thing is incredibly confusing. The thing is, they don't seem to mix and uses different methods such as .size() vs .length(). All of them also seem to be doing the same thing: having a group of something.

I really need a comparison of the three, and how to declare, manipulate, and access, etc them.

Top answer
1 of 5
16
These are three different things: Array - a very basic data structure. It has a fixed, predetermined size that must be known at the time of creating (instantiating) the array. Think of it as a sorting box with several slots. Here, you have .length - without parentheses as it is a property, not a method List - an interface (not a class) that defines certain behavior. It cannot be instantiated on its own. ArrayList - a concrete class that implements the List interface. When you see a declaration like List data = new ArrayList<>(); there are several things going on: Listprogramming against the interface - here, the interface List is used as data type - this is good practice as it allows you to at any time change the internal representation of the List - e.g. from ArrayList to LinkedList if you figure out that the other better suits your needs. this is a data type identifier. It limits the type of elements that can be stored in the list. Here, only String objects are allowed. If you were to omit this, the list would store Object (the ancestor of all Java classes) and descendant instances (i.e. Object and any subclass of it). data - just the variable name new - the keyword to create a new Object Instance ArrayList<>() - the constructor call. Here, the constructor without parameters of the ArrayList class is called. The diamond operator <> is used to infer (take) the data type for the ArrayList from the variable type (here String). So, the whole is: we create a new variable of type List that can only accept String elements and ist internally represented as ArrayList.
2 of 5
4
Array An array is a data structure built into the Java language which can hold a number of elements, all of the same type. It cannot be resized once it has been created, and you cannot add elements to it without specifying an index. // creates an array of 10 ints int[] arr = new int[10]; // sets the value of the 0th element to 5 arr[0] = 5; // prints the value of the 0th element, which is 5 System.out.println(arr[0]); // Sets e to the value of the 0th element of arr, which is 5 int e = arr[0]; // Sets the value of the 1st element to 6 arr[1] = 6; // prints the length of arr System.out.println(arr.length); // even though arr[9] has not been set, // all elements initialize to 0 when first created System.out.println(arr[9]); /* Illegal operations! */ // an exception is thrown since arr can only hold 10 elements System.out.println(arr[11]); // there is no shorthand syntax to get the last element of an array System.out.println(arr[-1]); // length is a variable, not a method System.out.println(arr.length()); // arr can only hold ints arr[2] = "Hello"; List A List is an class that is part of the Java Standard Library which allows for dynamic insertion and deletion of elements. You can't just create a List though, you have to use one of its subclasses, which includes ArrayList, and you have to use generics as well. Think of an ArrayList as a dynamic version of an array, and is the closest thing to Python's list datatype. // Make sure to import these at the top of your class! import java.util.List; import java.util.ArrayList; // creates an ArrayList of ints List myList = new ArrayList<>(); // adds 5 to myList myList.add(5); // prints the 0th element of myList, which is 5 System.out.println(myList.get(0)); myList.add(6); // removes the last element of myList, which is 6 int removed = myList.remove(); // prints the size of the list, which is 1 System.out.println(myList.size()); /* Illegal operations! */ // myList only has 1 element System.out.println(list.get(5)); myList.remove(); // removes 5 // throws an exception since the list is empty myList.remove(); // throws an exception since myList can only take ints myList.add("Hello"); // you can only use bracket notation on arrays System.out.println(myList[0]); // size is a method, not a variable System.out.println(myList.size); Other Info There are lots of other List subclasses you can use depending on the kind of operations you want to do on it, such as Queues, LinkedLists, and PriorityQueues. The reason why we use Integer instead of int when working with Lists is a limitation of the Java language. Generic types can only be object types, but primitive types, such as int, double, boolean, etc., are not object types, and thus we have to use autoboxing to work with primitives in this manner.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-array-of-arraylist-of-array
Java Array of ArrayList, ArrayList of Array | DigitalOcean
August 4, 2022 - If you are not sure about the type of objects in the array or you want to create an ArrayList of arrays that can hold multiple types, then you can create an ArrayList of an object array. Below is a simple example showing how to create ArrayList of object arrays in java.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-arraylist-of-arrays
Java ArrayList of Arrays - GeeksforGeeks
October 8, 2021 - Print ArrayList of Array. Below is the implementation of the above approach: ... // Java ArrayList of Arrays import java.io.*; import java.util.*; class GFG { public static void main(String[] args) { // create an ArrayList of String Array type ArrayList<String[]> list = new ArrayList<String[]>(); // create a string array called Names String names[] = { "Rohan", "Ritik", "Prerit" }; // create a string array called Age String age[] = { "23", "20" }; // create a string array called address String address[] = { "Lucknow", "Delhi", "Jaipur" }; // add the above arrays to ArrayList Object list.add(names); list.add(age); list.add(address); // print arrays from ArrayList for (String i[] : list) { System.out.println(Arrays.toString(i)); } } }
🌐
GeeksforGeeks
geeksforgeeks.org › java › array-vs-arraylist-in-java
Array vs ArrayList in Java - GeeksforGeeks
June 5, 2026 - An array has a fixed size, while ArrayList is dynamic and part of the Java Collections Framework, offering more built-in methods for easy data manipulation.
🌐
Reddit
reddit.com › r/learnprogramming › java: is arraylist better than arrays?
r/learnprogramming on Reddit: Java: Is Arraylist better than Arrays?
June 23, 2024 -

I've been programming in Java for 10 months now (as a subject in school) and i was always curious whats the biggest difference between Areays and Arraylist. I know that if i had an Arraylist named 'list' and i wrote System.out.print(list) it will print all the things that the list contains. Something that Arrays can't do that easily. But whats the actually biggest difference?