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 - One straightforward idea to solve our problem is to walk through the string ArrayList, take every element, and fill a predeclared string array.
🌐
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); } } }...
🌐
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 - To understand this example, you ... languages); // convert the arraylist into a string String arraylist = languages.toString(); System.out.println("String: " + arraylist); } }...
🌐
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.
🌐
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.
🌐
Blogger
javahungry.blogspot.com › 2017 › 11 › how-to-convert-arraylist-to-string-array-java-example.html
Convert ArrayList to String array in Java with Example | Java Hungry
In this example we have converted the whole list to array in three steps a. Obtain the ArrayList size using size() method b. Fetch each element of the list using get() method c. Assigned each element to corresponding array element using assignment = operator d. Print String array
Find elsewhere
🌐
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.
🌐
YouTube
youtube.com › software testing and automation
31 - Java Program To Convert ArrayList To String Array | Two Different Ways - YouTube
Here is the link of Full Play List ► https://bit.ly/2ZGeBFCHere we will learn 2 different ways to Convert ArrayList To String Array.1. Using ArrayList get()...
Published: February 8, 2021
Views: 4K
🌐
Vultr
docs.vultr.com › java › standard library › java › util › arraylist › tostring()
Java ArrayList toString() - Convert To String
November 19, 2024 - The toString() method in Java's ArrayList class is a convenient way to convert the entire contents of the ArrayList into a single String.
🌐
Edureka Community
edureka.co › home › community › categories › java › convert arraylist string to string array
Convert ArrayList String to String array | Edureka Community
December 22, 2020 - 100412/convert-arraylist-string-to-string-array · Home · Community · Categories · Java · Convert ArrayList String to String array · how do I turn a double in an array from 1000 to infinity Jul 9, 2024 · I have created a code in java for a flower shop and now my IDE is showing all the inputs are in red showing there is an error Jul 6, 2024 ·
🌐
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 - By understanding how to convert between ArrayList and String, you leverage Java's capabilities to manipulate collections and strings effectively for various needs, from simple formatting changes to complex data processing. Apply these methods to ensure your code is efficient and adaptable to different types of data handling scenarios. ... Round a number to n decimal placesImplement multiple inheritanceCalculate union of two setsImplement the graph data structureConvert array to set (hashset) and vice-versa
🌐
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 - In the following code, we iterate through the given list using a for-each loop and explicitly convert every object to a String by calling toString() on it: List<String> outputList = new ArrayList<>(inputList.size()); for(Object obj : inputList){ ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › system.collections.arraylist.toarray
ArrayList.ToArray Method (System.Collections) | Microsoft Learn
Dim myAL As New ArrayList() ... contains the following values:") PrintIndexAndValues(myAL) ' Copies the elements of the ArrayList to a string array....
🌐
Codemia
codemia.io › home › knowledge hub › best way to convert an arraylist to a string
Best way to convert an ArrayList to a string | Codemia
January 26, 2025 - If you want 1,2,3,4 or 1 | 2 | 3 | 4, convert the elements to strings and join them. ... 1import java.util.ArrayList; 2import java.util.Arrays; 3import java.util.stream.Collectors; 4 5public class Main { 6 public static void main(String[] args) { 7 ArrayList<Integer> numbers = new ArrayList<>(Arrays.asList(1, 2, 3, 4)); 8 9 String csv = numbers.stream() 10 .map(String::valueOf) 11 .collect(Collectors.joining(",")); 12 13 System.out.println(csv); 14 } 15}