List<String> list = ..;
String[] array = list.toArray(new String[0]);

For example:

List<String> list = new ArrayList<String>();
//add some stuff
list.add("android");
list.add("apple");
String[] stringArray = list.toArray(new String[0]);

The toArray() method without passing any argument returns Object[]. So you have to pass an array as an argument, which will be filled with the data from the list, and returned. You can pass an empty array as well, but you can also pass an array with the desired size.

Important update: Originally the code above used new String[list.size()]. However, this blogpost reveals that due to JVM optimizations, using new String[0] is better now.

Answer from Bozho on Stack Overflow
🌐
Baeldung
baeldung.com › home › java › java string › convert an arraylist of string to a string array in java
Convert an ArrayList of String to a String Array in Java | Baeldung
March 7, 2025 - In this tutorial, we’ll explore how to accomplish this conversion seamlessly using Java’s built-in methods and techniques. An example can help us to understand the problem quickly. Let’s say we have the following ArrayList, which contains some artists’ names: static final List<String> INPUT_LIST = Lists.newArrayList("Michael Bolton", "Michael Jackson", "Guns and Roses", "Bryan Adams", "Air Supply"); Now, we want to convert this ArrayList to a String array, which contains the same artists’ names in the same order:
🌐
BeginnersBook
beginnersbook.com › 2013 › 12 › how-to-convert-arraylist-to-string-array-in-java
How to convert ArrayList to string array in java
We are converting this arraylist ... names.add("Harsh"); names.add("John"); // ArrayList to Array Conversion using toArray() String arr[]=names.toArray(new String[names.size()]); //Print array elements for(String str: arr) { System.out.println(str); } } } Output: Ankur Ajeet ...
🌐
Programiz
programiz.com › java-programming › examples › arraylist-string-conversion
Java Program to Convert the ArrayList into a string and vice versa | Programiz
March 14, 2024 - import java.util.ArrayList; class ... languages); // convert the arraylist into a string String arraylist = languages.toString(); System.out.println("String: " + arraylist); } }...
🌐
Coderanch
coderanch.com › t › 377381 › java › convert-ArrayList-Strings-String
convert an ArrayList of Strings into String[] ? (Java in General forum at Coderanch)
July 31, 2005 - ArrayList aL = getStringObj(); But "aL.toArray();" can only return me an array of Objects ? Of course, I can do Iterator i = aL.iterator(); String s = new String[aL.size()]; int i = 0; while(i.hasNext()) { s[i++] = i.next().toString(); } return s; where "s" is an array of Strings.
Find elsewhere
🌐
Codemia
codemia.io › home › knowledge hub › convert arraylist to string[] array
Convert ArrayList<String> to String[] array | Codemia
January 2, 2025 - When programming in Java, a common requirement is to convert an ArrayList<String> to a String[] array. This is particularly useful when working with older APIs or libraries that do not accept collections as input.
🌐
Javatpoint
javatpoint.com › convert-arraylist-to-string-array-in-java
Convert ArrayList to String Array in Java - Javatpoint
Convert ArrayList to String Array in Java with java tutorial, features, history, variables, object, programs, operators, oops concept, array, string, map, math, methods, examples etc.
🌐
Mkyong
mkyong.com › home › java › java – convert arraylist to string[]
Java – Convert ArrayList<String> to String[] | mkyong.com
April 17, 2019 - java April 23, 2019 1 min read by mkyong 0 comments · In the old days, we can use list.toArray(new String[0]) to convert a ArrayList<String> into a String[] StringArrayExample.java ·
🌐
Vultr Docs
docs.vultr.com › java › examples › convert-the-arraylist-into-a-string-and-vice-versa
Java Program to Convert the ArrayList into a string and vice versa | Vultr Docs
December 19, 2024 - In Java, converting data between different formats is a common task that developers encounter. Specifically, the conversion between ArrayList and String is quite useful, especially when dealing with data that needs to be easily serialized or passed among different components or systems that handle data as strings.
🌐
Baeldung
baeldung.com › home › java › java list › convert an arraylist of object to an arraylist of string elements
Convert an ArrayList of Object to an ArrayList of String Elements | Baeldung
March 7, 2025 - Let’s try to use Java Collections to solve our problem. The idea is to iterate through the elements of the list and convert each element into a String. Once done, we have a list of String objects.
🌐
How to do in Java
howtodoinjava.com › home › java array › convert list to array in java and an array back to a list
Convert List to Array in Java and an Array Back to a List
January 12, 2023 - Because of type erasure, the list does not know at runtime that it holds strings, so we pass the array type ourselves with toArray(String[]::new) or toArray(new String[0]). List<String> cities = new ArrayList<>(List.of("Pune", "Oslo")); Object[] objects = cities.toArray(); // [Pune, Oslo] String[] typed = cities.toArray(String[]::new); // [Pune, Oslo] String[] typed2 = cities.toArray(new String[0]); // [Pune, Oslo] String[] broken = (String[]) cities.toArray(); // ClassCastException
🌐
Programiz
programiz.com › java-programming › library › arraylist › tostring
Java ArrayList toString() | Programiz
March 12, 2024 - The Java ArrayList toString() method converts an arraylist into a String.
🌐
Board Infinity
boardinfinity.com › blog › how-to-convert-arraylist-to-array-in-java
Convert ArrayList to Array in Java | Board Infinity
June 16, 2026 - It is concise, type-safe, and useful in generic code because the list itself asks the generator to create an array of the right size. This variant is especially readable when converting lists of domain objects. A familiar example is converting a list of IRCTC PNR status labels into a String[] for a report template. A healthcare example is converting ArrayList<PatientReading> into PatientReading[] before feeding it into a rules module that evaluates abnormal vitals. The method is ideal in Java 11+ codebases where constructor references are already common with streams and functional interfaces.
🌐
Dot Net Perls
dotnetperls.com › convert-arraylist-string-java
Java - Convert ArrayList to String - Dot Net Perls
Result The ArrayList's contents ... main(String[] args) { // Create an ArrayList and add three strings to it. ArrayList<String> arr = new ArrayList<>(); arr.add("cat"); arr.add("dog"); arr.add("bird"); // Convert the ArrayList into a String....
🌐
GeeksforGeeks
geeksforgeeks.org › java › convert-arraylist-to-comma-separated-string-in-java
Convert ArrayList to Comma Separated String in Java - GeeksforGeeks
July 23, 2025 - The joining() method of Collectors Class, in Java, is used to join various elements of a character or string array into a single string object. ... // Java Program to Convert ArrayList to // Comma Separated String // Using Stream API // Importing ...