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
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-string-array-to-string
Java String Array to String | DigitalOcean
August 3, 2022 - Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Discussions

How to convert object to string ?
Usually toString() method can be overridden by any class to acheive this. In your case MyDate class. Overrid toString() and add your own logic and to return formatted date. More on reddit.com
🌐 r/javahelp
4
2
October 7, 2020
Convert Java object to JSON without external library
Converting arbitrary objects to JSON isn't particularly easy, especially when there are full solutions already available. Personally, I use Gson, which is pretty easy to use. If the no external libraries is a HARD requirement, then your only choice would be to use reflection to get the names and values of the fields of the object to build the JSON string. You might have recursion problems if there are nested objects that create a circular loop, which complicates things. If you only have to serialize specific classes, then it would probably be easier to essentially hardcode the JSON string generation, and just call the appropriately getters to build the string. Basically, if it's only a few specific classes then you can write your own, if it's any arbitrary object then I highly recommend using a library, but if no libraries then I guess you could try homerolling your own JSON serializer with reflection. More on reddit.com
🌐 r/javahelp
12
1
May 1, 2020
converting String to WebElement
It is difficult to diagnose exactly what is going on with complete certainty from just the one line, but based on your description of the problem it seems likely that you are attempting to use an uninitialized web driver. Earlier in your program (before the line of code you posted) do you have a statement like this: WebDriver driver = new ChromeDriver();// or FirefoxDriver If not, you’ll need to add it in. In java objects aren’t initialised by default, so just having a declaration to the effect of “WebDriver driver;” won’t suffice, you’ll need to instantiate a driver instance with the new keyword. More on reddit.com
🌐 r/learnprogramming
1
0
January 3, 2020
Error: "Type mismatch: cannot convert from String to int"
next() returns a String. Are you looking for nextInt()? More on reddit.com
🌐 r/javahelp
9
3
September 24, 2019
🌐
W3Schools
w3schools.com › JAVA › ref_string_tostring.asp
Java String toString() Method
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 ... The toString() method returns the string itself.
🌐
Oracle
docs.oracle.com › javase › tutorial › java › data › converting.html
Converting Between Numbers and Strings (The Java™ Tutorials > Learning the Java Language > Numbers and Strings)
See Java Language Changes for a ... in Java SE 9 and subsequent releases. See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases. Frequently, a program ends up with numeric data in a string object—a value entered by the user, for example. The Number subclasses that wrap primitive numeric types ( Byte, Integer, Double, Float, Long, and Short) each provide a class method named valueOf that converts a string to an object ...
🌐
Codementor
codementor.io › blog › java string basics and java string conversions
Java String Basics and Java String Conversions
October 29, 2021 - Another way to work with Strings is to convert characters into a String. We will go into this in the last section of the tutorial. If you want to find out how many characters are in a String, you can simply use the length() method. Here’s an example: public class JavaStringLength{ public static void main(String args[]){ String txt = "Need to learn how to apply Java String to your projects?"; System.out.println("The length of the txt String is: " + txt.length()); }}
🌐
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 - ... // Java Program to Convert String to String Array // Using str.split() method // Importing input output classes import java.io.*; // Main class public class GFG { // Main driver method public static void main(String[] args) { // Input string ...
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › java › string-tostring-method-in-java
toString() Method in Java - GeeksforGeeks
December 17, 2025 - The toString() method is defined in the java.lang.Object class and returns a string representation of an object. It is commonly overridden to provide meaningful, human-readable details about an object's state and is automatically invoked when ...
🌐
javathinking
javathinking.com › blog › how-do-you-convert-something-tostring-java
How to Convert Something to String in Java — javathinking.com
It can accept various data types, including primitive types and objects, and return a string representation of the given argument. This method is a convenient way to convert different types to strings without having to worry about null values. Java allows you to concatenate strings using the + operator.
🌐
Tutorialspoint
tutorialspoint.com › java › lang › string_tostring.htm
Java - String toString() Method
A string in Java is a group of characters that is an object of the Java lang class. The string class in Java is used to create and modify strings. A string cannot have its value modified after it has been created. There is no need to call this method on a string object explicitly, it just returns the current string without making any changes.
🌐
YouTube
youtube.com › talented developer
Java Program to Convert String to Int and Int to String | String to Int and vice-versa - YouTube
#stringtoint #inttostring #stringconversionJava Program to Convert String to Int and Int to String | String to Int and vice-versaCode Location: https://gith...
Published: March 4, 2023
🌐
Baeldung
baeldung.com › home › java › java string › java string conversions
Java String Conversions | Baeldung
August 17, 2023 - Quick and practical examples focused on converting String objects to different data types in Java.
🌐
Rutgers CS
cs.rutgers.edu › courses › 111 › classes › fall_2011_tjang › texts › notes-java › data › strings › conversion › num2string.html
Java: Converting Numbers to Strings
If either operand of a concatenation is a string, the other operand is converted to string, regardless of whether it is a primitive or object type.
🌐
W3Schools
w3schools.com › java › java_ref_string.asp
Java String Reference
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 ... The String class has a set of built-in methods that you can use on strings. ... Coding fundamentals as bite-sized lessons and challenges. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com
🌐
Quora
quora.com › How-do-I-convert-string-array-to-string-in-Java
How to convert string array to string in Java - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
🌐
Baeldung
baeldung.com › home › java › java string › how to convert an object to string
How to Convert an Object to String | Baeldung
January 5, 2024 - This results in the string representation of the person object. We can also convert an object to a String through the technique of String concatenation.
🌐
GeeksforGeeks
geeksforgeeks.org › java › stringbuilder-tostring-method-in-java-with-examples
StringBuilder toString() method in Java with Examples - GeeksforGeeks
August 18, 2026 - Preserves the current content: The returned String represents the contents at the time toString() is called. Converts StringBuilder content into a String.
🌐
Baeldung
baeldung.com › home › java › java string › array to string conversions
Array to String Conversions | Baeldung
September 16, 2026 - The default implementation of the toString() method on an array returns something like Ljava.lang.String;@74a10858 which only informs us of the object’s type and hash code. However, the java.util.Arrays utility class supports array and string ...
🌐
MIT
web.mit.edu › java_v1.0.2 › www › tutorial › java › strings › conversion.html
Converting Objects to Strings
class ReverseString { public static String reverseIt(String source) { int i, len = source.length(); StringBuffer dest = new StringBuffer(len); for (i = (len - 1); i >= 0; i--) { dest.append(source.charAt(i)); } return dest.toString(); } } It's often convenient or necessary to convert an object to a String because you need to pass it to a method that accepts only String values.
🌐
Snible
snible.org › java2 › uni2java.html
Unicode to Java string literal converter - Ed
Cut and paste symbol font text into the 'Unicode' field and click 'Convert!' to get Java string literal translation.