In this Java tutorial, you will learn how to convert a String array to an ArrayList<String> using the ArrayList constructor, a for loop, addAll(), and the Stream API.

Convert String Array to ArrayList in Java

The simplest way to convert a String[] to a modifiable ArrayList<String> is to pass the list returned by Arrays.asList() to the ArrayList constructor.

</>
Copy
ArrayList<String> nameList = new ArrayList<>(Arrays.asList(names));

This creates a new, independently modifiable ArrayList. You can add, remove, or replace elements without changing the size of the original array.

String Array to ArrayList Using the ArrayList Constructor

Use this approach when you want a concise conversion and need the resulting list to support operations such as add() and remove().

Example.java

</>
Copy
import java.util.ArrayList;
import java.util.Arrays;

public class Example {
    public static void main(String[] args) {
        String[] names = {"Java", "Kotlin", "Android"};

        ArrayList<String> nameList =
                new ArrayList<>(Arrays.asList(names));

        nameList.add("Swift");
        nameList.remove("Kotlin");

        System.out.println(nameList);
    }
}

Output

[Java, Android, Swift]

The constructor copies the references from the array-backed list into a new ArrayList. Structural changes to nameList therefore do not change the original array.

String Array to ArrayList Examples

1. String[] to ArrayList<String> using For Loop

In the following example, we will initialize an empty ArrayList and add the items of string array one by one to this ArrayList using a For loop.

Example.java

</>
Copy
import java.util.ArrayList;

public class Example {

	public static void main(String[] args) {
		
		// string array
		String[] names = {"Java","Kotlin","Android"};
		
		// declare an arraylist that hold strings
		ArrayList<String> nameList = new ArrayList<String>();
		
		// add each element of string array to arraylist
		for(String name:names) {
			nameList.add(name);
		}
		
		// print the arraylist
		nameList.forEach(name ->{
			System.out.println(name);
		});
	}
}

Output

Java
Kotlin
Android

A loop is useful when each value must be validated or transformed before it is added. For example, you can skip blank strings or convert every value to uppercase during the conversion.

2. String Array to ArrayList using ArrayList.addAll() and Arrays.asList()

To convert String Array to ArrayList, we can make use of Arrays.asList() function and ArrayList.addAll().

Arrays.asList(String[]) returns List<String> with elements of String[] loaded to List<String>.

Now, we can make use of ArrayList.addAll(List<String>) that adds elements of List to the ArrayList.

Example.java

</>
Copy
import java.util.ArrayList;
import java.util.Arrays;

public class Example {

	public static void main(String[] args) {
		
		// string array
		String[] names = {"Java","Kotlin","Android"};
		
		// declare an arraylist that hold strings
		ArrayList<String> nameList = new ArrayList<String>();
		
		// add elements of array to arraylist
		nameList.addAll(Arrays.asList(names));
		
		// print the arraylist
		nameList.forEach(name ->{
			System.out.println(name);
		});
	}
}

Output

Java
Kotlin
Android

This method is useful when an existing ArrayList already contains values and the array elements need to be appended to it.

3. Convert String Array to ArrayList Using Java Streams

The Stream API is useful when the array values must be filtered or transformed during conversion. The following example removes blank values, trims whitespace, and collects the remaining strings into an ArrayList.

Example.java

</>
Copy
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Example {
    public static void main(String[] args) {
        String[] names = {" Java ", "", "Kotlin", " Android "};

        ArrayList<String> nameList = Arrays.stream(names)
                .filter(name -> name != null && !name.isBlank())
                .map(String::trim)
                .collect(Collectors.toCollection(ArrayList::new));

        System.out.println(nameList);
    }
}

Output

[Java, Kotlin, Android]

Arrays.asList() Is Not an ArrayList

A common mistake is to assign the result of Arrays.asList() directly to an ArrayList. The method returns a fixed-size List backed by the original array, not a java.util.ArrayList.

</>
Copy
import java.util.Arrays;
import java.util.List;

public class Example {
    public static void main(String[] args) {
        String[] names = {"Java", "Kotlin", "Android"};
        List<String> nameList = Arrays.asList(names);

        nameList.set(0, "Python"); // Allowed
        // nameList.add("Swift");  // Throws UnsupportedOperationException

        System.out.println(Arrays.toString(names));
    }
}

Output

[Python, Kotlin, Android]

Calling set() changes the corresponding element in the original array because the list is backed by that array. Calling add() or remove() is not supported because those operations would change the list size.

Choose the Right String Array Conversion Method

RequirementRecommended approach
Create a normal, modifiable ArrayListnew ArrayList<>(Arrays.asList(array))
Append array values to an existing ArrayListarrayList.addAll(Arrays.asList(array))
Validate or transform each element manuallyEnhanced for loop
Filter and transform values as a pipelineArrays.stream(array)
Need only a fixed-size List viewArrays.asList(array)

Null and Duplicate Values in the Converted ArrayList

The standard conversion methods preserve element order, duplicate strings, and null values. They do not automatically remove or validate any array element.

</>
Copy
String[] values = {"Java", null, "Java"};
ArrayList<String> list = new ArrayList<>(Arrays.asList(values));

System.out.println(list);

Output

[Java, null, Java]

Use a loop or stream filter when null, blank, or duplicate values must be handled differently.

String Array to ArrayList FAQs

What is the shortest way to convert a String array to an ArrayList?

Use new ArrayList<>(Arrays.asList(names)). It creates a modifiable ArrayList<String> containing the array elements in the same order.

Can I add elements to the list returned by Arrays.asList()?

No. The returned list has a fixed size. Its existing elements can be replaced with set(), but add() and remove() throw UnsupportedOperationException.

Does changing an ArrayList change the original String array?

Not when the list is created with the ArrayList constructor or populated using addAll(). Those approaches create a separate list structure. A list returned directly by Arrays.asList(), however, remains backed by the array.

Are duplicate and null strings preserved during conversion?

Yes. Standard conversion methods preserve duplicates, null values, and the original element order unless you explicitly filter or transform them.

String Array to ArrayList Editorial QA Checklist

  • Confirm that examples requiring a modifiable list create a new ArrayList.
  • Do not describe the object returned by Arrays.asList() as a resizable ArrayList.
  • Verify that examples preserve the distinction between modifying list elements and changing list size.
  • Use a loop or stream only when filtering, validation, or transformation is part of the example.
  • Check that all Java examples import Arrays, ArrayList, and stream classes where required.

Summary of String Array to ArrayList Conversion

In this Java Tutorial, we learned several ways to convert a String array to an ArrayList. For a direct conversion to a modifiable list, use new ArrayList<>(Arrays.asList(array)). Use addAll() to append values to an existing list, a for loop for explicit element handling, or streams when filtering and transformation are required.