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
๐ŸŒ
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
๐ŸŒ
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.
๐ŸŒ
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 ...
๐ŸŒ
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.
๐ŸŒ
Hostman
hostman.com โ€บ tutorials โ€บ converting-arrays-and-strings-in-java
Java Array to String and String to Array Conversion Guide
In Java, strings are treated as objects, and the language furnishes a robust set of methods for the manipulation of textual information. This tutorial provides a comprehensive guide on how to convert arrays to strings and strings to arrays in Java.
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 โ€บ 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 - That is to say, at runtime, the array returned by the toArray() method doesnโ€™t know its elementsโ€™ concrete types. They could be String, Integer, or even mixed by different types since the Object class is the supertype of all other types.
Find elsewhere
๐ŸŒ
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.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ java โ€บ string-arrays-in-java
String Arrays in Java - GeeksforGeeks
October 2, 2025 - A String Array in Java is an array that stores string values. In this article, we will learn the concepts of String Arrays in Java including declaration, initialization, iteration, searching, sorting, and converting a String Array to a single string.
๐ŸŒ
Tutorial Gateway
tutorialgateway.org โ€บ java-array-to-string
Java toString to Convert Array to String
August 9, 2026 - The Java array toString Method returns the string representation of the specified array, and this article shows you how to convert the Array to a string.
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ dotnet โ€บ api โ€บ java.util.arrays.tostring
Arrays.ToString Method (Java.Util) | Microsoft Learn
Returns a string representation of the contents of the specified array. The string representation consists of a list of the array's elements, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (a comma ...
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ java-string-array-to-string
Java String Array to String | DigitalOcean
August 3, 2022 - From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
Top answer
1 of 4
3

If the individual strings might themselves include a comma followed by a space, then this would not be feasible. Multiple String[] arrays could map to the same flat String, and an inverse function would not exist.

However, you note in a comment that your strings cannot include the comma separator. You can split the flat string back into the original substrings, using ", " (comma,space) as a separator.

APIs that support this include the standard Java String.split() method, and Guava's Splitter class.

Here's an example with Java's split() method:

public static void main(String[] args) {
    String[] strs = new String[] { "Foo", "Bar", "Baz" };

    String joined = Arrays.toString( strs );

    String joinedMinusBrackets = joined.substring( 1, joined.length() - 1);

    // String.split()
    String[] resplit = joinedMinusBrackets.split( ", "); 

    for ( String s : resplit ) {
        System.out.println( s );
    }

}

And here's an example with Guava's Splitter class:

public static void main(String[] args) {
    String[] strs = new String[] { "Foo", "Bar", "Baz" };

    String joined = Arrays.toString( strs );

    String joinedMinusBrackets = joined.substring( 1, joined.length() - 1);

    // Guava Splitter class
    List<String> resplitList = Splitter.on( ", " ).splitToList( joinedMinusBrackets );

    for ( String s : resplitList ) {
        System.out.println( s );
    }
}
2 of 4
1

I guess that's the answer you're searching for. Briefly, it's about using serialization with apache codecs for encoding/decoding objects. I don't want to do copy/paste from another answer, so I'll give you only the code sample in case link changes someday. Here it is:

  // serialize
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    new ObjectOutputStream(out).writeObject(yourArray);

 //encode
    String encodeString = new String(Hex.encodeHex(out.toByteArray()));

 // deserialize
    ByteArrayInputStream in = new ByteArrayInputStream(Hex.decodeHex(yourString.toCharArray()));
    String yourArray = Arrays.toString((String[]) new ObjectInputStream(in).readObject());
}
// And then you could use `String#split()` method to convert string to array.

Another option is to use something like Gson JSON library, with Gson, you can convert any java object to a json string and then convert it back. Example code may looks like this:

//Put an array (or any other object to gson object
Gson gson = new Gson();
String json = gson.toJson(yourArray);

// Retrieve your object from gson
Gson gson = new Gson();
Array array = gson.fromJson(json, Array.class);

For more details you look this article.

๐ŸŒ
Centron
centron.de โ€บ home โ€บ tutorials โ€บ java string array - tutorial
Java String Array - Tutorial โ€“ centron
February 6, 2025 - The second statement is true because when converted to String, their values are the same and String class equals() method implementation checks for values. For more details, please check the String class API documentation.
๐ŸŒ
Edureka Community
edureka.co โ€บ home โ€บ community โ€บ categories โ€บ java โ€บ how an object array can be converted to string...
How an object array can be converted to string array in java | Edureka Community
June 8, 2018 - I use the following code to convert an Object array to a String array : Object Object_Arr[]=new Obj[ ... I wonder if there is another way to do this?