Java 8+

Use String.join():

String str = String.join(",", arr);

Note that arr can also be any Iterable (such as a list), not just an array.

If you have a Stream, you can use the joining collector:

Stream.of("a", "b", "c")
      .collect(Collectors.joining(","))

Legacy (Java 7 and earlier)

StringBuilder builder = new StringBuilder();
for(String s : arr) {
    builder.append(s);
}
String str = builder.toString();

Alternatively, if you just want a "debug-style" dump of an array:

String str = Arrays.toString(arr);

Note that if you're really legacy (Java 1.4 and earlier) you'll need to replace StringBuilder there with StringBuffer.

Android

Use TextUtils.join():

String str = TextUtils.join(",", arr);

General notes

You can modify all the above examples depending on what characters, if any, you want in between strings.

DON'T use a string and just append to it with += in a loop like some of the answers show here. This sends the GC through the roof because you're creating and throwing away as many string objects as you have items in your array. For small arrays you might not really notice the difference, but for large ones it can be orders of magnitude slower.

Answer from Michael Berry on Stack Overflow
Top answer
1 of 14
642

Java 8+

Use String.join():

String str = String.join(",", arr);

Note that arr can also be any Iterable (such as a list), not just an array.

If you have a Stream, you can use the joining collector:

Stream.of("a", "b", "c")
      .collect(Collectors.joining(","))

Legacy (Java 7 and earlier)

StringBuilder builder = new StringBuilder();
for(String s : arr) {
    builder.append(s);
}
String str = builder.toString();

Alternatively, if you just want a "debug-style" dump of an array:

String str = Arrays.toString(arr);

Note that if you're really legacy (Java 1.4 and earlier) you'll need to replace StringBuilder there with StringBuffer.

Android

Use TextUtils.join():

String str = TextUtils.join(",", arr);

General notes

You can modify all the above examples depending on what characters, if any, you want in between strings.

DON'T use a string and just append to it with += in a loop like some of the answers show here. This sends the GC through the roof because you're creating and throwing away as many string objects as you have items in your array. For small arrays you might not really notice the difference, but for large ones it can be orders of magnitude slower.

2 of 14
106

Use Apache commons StringUtils.join(). It takes an array, as a parameter (and also has overloads for Iterable and Iterator parameters) and calls toString() on each element (if it is not null) to get each elements string representation. Each elements string representation is then joined into one string with a separator in between if one is specified:

String joinedString = StringUtils.join(new Object[]{"a", "b", 1}, "-");
System.out.println(joinedString);

Produces:

a-b-1
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java string โ€บ array to string conversions
Array to String Conversions | Baeldung
September 16, 2026 - Sometimes we need to convert an array of strings or integers into a string, but unfortunately, there is no direct method to perform this conversion.
Discussions

string to string array conversion in java - Stack Overflow
I have a string = "name"; I want to convert into a string array. How do I do it? Is there any java built in function? Manually I can do it but I'm searching for a java built in function. I want an... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Java- Converting a string of numbers separated by spaces into an array?
You have the right idea. String.split() will return an array of strings. Then, if you want to treat any individual string in that array as an integer you can use Integer.parseInt() . If you want to create an array of integers, just make the array that way. More on reddit.com
๐ŸŒ r/learnprogramming
7
4
February 2, 2016
How to convert a String array to a String while still keeping the individual parts?
String.join(", ", array); or if you want no space between individual array items String.join("", array); More on reddit.com
๐ŸŒ r/javahelp
8
6
April 4, 2018
Converting a String Array into an Array
This has nothing to do with Nextjs at allโ€ฆ? Itโ€™s a plain and simple JS question. Anyway the data format is obviously wrong. Perhaps you should look into making dynamoDB storing the data in a valid JSON format so you can just parse it. Trying to parse a JSON-like string is just unnecessary work when you couldโ€™ve fixed the source formatting instead. More on reddit.com
๐ŸŒ r/nextjs
4
0
August 4, 2023
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ arrays-tostring-in-java-with-examples
Arrays.toString() in Java with Examples - GeeksforGeeks
Converts an array into a string containing all its elements. For object arrays with nested arrays, it prints memory references instead of actual values. For nested arrays, Arrays.deepToString() should be used to get full content representation.
Published: April 14, 2026
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ java-string-array-to-string
Java String Array to String | DigitalOcean
August 3, 2022 - The Wave has everything you need to know about building a business, from raising funding to marketing your product.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ array to string in java
Array to String In Java | Scaler Topics
June 2, 2024 - In Java programming language, an array is a data structure that stores the same type of value in a contiguous memory location which we can access using the index, whereas a string is an object that stores a sequence of characters, so there can be some situation where we want to convert an array to string, so for this we have some methods like toString, StringBuilder append, etc.
๐ŸŒ
W3Schools
w3schools.com โ€บ java โ€บ java_howto_string_to_array.asp
Java How To Convert a String to an Array
Java Examples Java Videos Java Compiler Java Exercises Java Quiz Java Code Challenges Java Practice Problems Java Server Java Syllabus Java Study Plan Java Interview Q&A ... There are many ways to convert a string to an array.
Find elsewhere
๐ŸŒ
Coderanch
coderanch.com โ€บ t โ€บ 410604 โ€บ java โ€บ convert-Array-Strings-String
Can we convert Array of Strings to a String?? (Beginning Java forum at Coderanch)
June 2, 2008 - In your code snippet "str" is a array of string and not a string if you want to pass the String array inside the function you can use public functionname(String[] a) { //method body } if you want to convert your string array into a single array use the following code snippet in your program ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ string-arrays-in-java
String Arrays in Java - GeeksforGeeks
October 2, 2025 - So generally we have three ways to iterate over a string array. The first method is to use a for-each loop. The second method is using a simple for loop. And the third method is to use a while loop.
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ dotnet โ€บ api โ€บ java.util.arrays.tostring
Arrays.ToString Method (Java.Util) | Microsoft Learn
The string representation consists ... ", " (a comma followed by a space). Elements are converted to strings as by String.valueOf(short)....
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java string โ€บ convert string to string array
Convert String to String Array | Baeldung
January 8, 2024 - We often need to work with input strings in specific patterns. In this case, we can break the inputs into a String array using regular expressions or regex. Javaโ€™s String class provides the split() method to do this job.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ java-program-to-convert-string-to-string-array
Java Program to Convert String to String Array - GeeksforGeeks
July 23, 2025 - Print the string array. ... // Java Program to Convert String to String Array // Using HashSet and Set classes // Importing required classes from respective packages import java.io.*; import java.util.Arrays; import java.util.HashSet; import java.util.Set; // Main class class GFG { // Method 1 // To convert Set<String> to String[] public static String[] method(Set<String> string) { // Create String[] of size of setOfString String[] string_array = new String[string.size()]; // Copy elements from set to string array // using advanced for loop int index = 0; for (String str : string) { string_arr
๐ŸŒ
Quora
quora.com โ€บ How-do-I-convert-string-array-to-string-in-Java
How to convert string array to string in Java - Quora
Answer (1 of 10): Use Arrays.toString method public class ArrayToString { public static void main(String[] args) { String[] strArray = new String[]{"Java", "PHP", ".NET", "PERL", "C", "COBOL"}; String newString = Arrays.toString(strAr...
๐ŸŒ
CodeGym
codegym.cc โ€บ java blog โ€บ java arrays โ€บ string array in java
String Array in Java
May 11, 2023 - You can use the String.join() method to convert a String array to String in Java. This method returns a string concatenated by the given delimiter. The delimiter is copied for each element in the String join() method.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnprogramming โ€บ java- converting a string of numbers separated by spaces into an array?
r/learnprogramming on Reddit: Java- Converting a string of numbers separated by spaces into an array?
February 2, 2016 -

For example, I have String input which will look something like "5 6 6" but I need it to be converted into an array. What is the easiest way to do this? I have messed around with .split and .parseInt but have not come to any solid conclusions. Thanks!

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ how-to-convert-an-array-to-string-in-java
How to Convert an Array to String in Java? - GeeksforGeeks
July 12, 2025 - The most simple method is the Arrays.toString() to convert an array to a string. ... // Java Program to convert an array to a string // using Arrays.toString() method import java.io.*; import java.util.Arrays; class GFG { public static void ...
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ string-to-array-in-java-how-to-convert-a-string-to-an-array-in-java
String to Array in Java โ€“ How to Convert Strings to Arrays
July 6, 2023 - Being able to convert a string into an array can be quite helpful when you're developing text-processing applications or working with data. A string in Java is a group of characters, whereas an array is a collection of the same type of element.
๐ŸŒ
Just Academy
justacademy.co โ€บ blog-detail โ€บ how-to-convert-string-array-to-string-in-java
How To Convert String Array To String In Java by Roshan Chaturvedi | JustAcademy
1 - Use a StringBuilder: Iterate through the string array and append each element to a StringBuilder object. Finally, call the `toString()` method on the StringBuilder to get the desired string.
๐ŸŒ
CodeGym
codegym.cc โ€บ java blog โ€บ strings in java โ€บ array to string in java
Array to String in Java
November 27, 2023 - Sometimes, you might need a bit more control over how you convert the array to string. Maybe you're not a fan of those square brackets, or you need a specific separator between elements. In such cases, Java's String.join() and good old loops come to the rescue.