Convert Array to ArrayList in Java

In this tutorial you will learn how to convert array to arraylist in Java.

There are mainly two ways to convert a Java array to arraylist.

  • Using Arrays.asList() method
  • Using Collections.addAll() method

Below I have shared an example of each of these methods. In these examples we are converting string array to arraylist.

Also Read: Convert ArrayList to Array in Java

Convert Array to ArrayList in Java

Convert Array to ArrayList in Java

1. Using Arrays.asList() method

The asList() method of Arrays class directly converts an array to arraylist. It has following syntax.

 

Example

 

Output

C
C++
Java
Android
JavaScript

 

2. Using Collections.addAll() method

The addAll() method of Collections class can also be used for converting array to arraylist. It is faster than Arrays.asList() method. It has following syntax.

 

Example

 

Output

C
C++
Java
Android
JavaScript

 

Comment below if you have doubts related to above array to arraylist examples.

2 thoughts on “Convert Array to ArrayList in Java

Leave a Reply

Your email address will not be published. Required fields are marked *