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
June 10, 2026 - In this article, we illustrated how to convert an array to string and back again using core Java and popular utility libraries.
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
reduce an array to string
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
6
1
October 17, 2021
How to concatenate arrays into a string? [Java][Methods]
String[] stringValues = new String[input.length()]; This creates an empty String array. Thus, when you concatenate all the Strings in here you will get nothing. More on reddit.com
🌐 r/learnprogramming
4
0
May 1, 2016
🌐
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
🌐
W3Schools
w3schools.com › java › java_arrays.asp
Java Arrays
Java Examples Java Videos Java ... declaring separate variables for each value. To declare an array, define the variable type with square brackets [ ] : ... We have now declared a variable that holds an array of ...
🌐
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.
Find elsewhere
🌐
Scaler
scaler.com › home › topics › array to string in java
Array to String In Java | Scaler Topics
June 2, 2024 - O(n)O(n), where n is the length of the final string. We can use java stream API to convert an array to a string.
🌐
W3Schools
w3schools.com › java › java_howto_string_to_array.asp
Java How To Convert a String to an Array
Java Wrapper Classes Java Generics Java Annotations Java RegEx Java Threads Java Lambda Java Advanced Sorting ... How Tos Add Two Numbers Swap Two Variables Even or Odd Number Reverse a Number Positive or Negative Square Root Area of Rectangle Celsius to Fahrenheit Sum of Digits Check Armstrong Num Random Number Count Words Count Vowels in a String Remove Vowels Count Digits in a String Reverse a String Palindrome Check Check Anagram Convert String to Array Remove Whitespace Count Character Frequency Sum of Array Elements Find Array Average Sort an Array Find Smallest Element Find Largest Element Second Largest Array Min and Max Array Merge Two Arrays Remove Duplicates Find Duplicates Shuffle an Array Factorial of a Number Fibonacci Sequence Find GCD Check Prime Number ArrayList Loop HashMap Loop Loop Through an Enum
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › Arrays.html
Arrays (Java Platform SE 8 )
April 21, 2026 - Java™ Platform Standard Ed. 8 ... This class contains various methods for manipulating arrays (such as sorting and searching). This class also contains a static factory that allows arrays to be viewed as lists.
🌐
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!

🌐
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 - By Shittu Olumide 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 typ...
🌐
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.
🌐
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 ...
🌐
Centron
centron.de › startseite › java string array – tutorial
Java String Array - Tutorial
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.
🌐
Baeldung
baeldung.com › home › java › java string › convert string to string array
Convert String to String Array | Baeldung
January 8, 2024 - For case 2, we need to break the input string into pieces. However, how the result should be is entirely dependent on the requirement. For example, if we expect each element in the final array contains two adjacent characters from the input string, given “baeldung”, we’ll have String[]{ “ba”, “el”, “du”, “ng” }. Later, we’ll see more examples.
🌐
Reddit
reddit.com › r/javahelp › reduce an array to string
r/javahelp on Reddit: reduce an array to string
October 17, 2021 -

I come from a Ruby background, and am trying to get my feet wet using functional methods in Java. I'm having trouble understanding why the following example won't reduce an array of integers down to a string.

import java.util.Arrays;

import java.util.List;

import java.util.stream.*;

public class ReduceTest {
    public static void main(String[] args) {
	int[] numbers = {1,2,3,4,5};
	IntStream stream = [Arrays.stream](https://Arrays.stream)(numbers);
	String output = stream.reduce("",(int string, int number) -> string + Integer.toString(number));
    }
}

I'm getting the error:

The method reduce(int, IntBinaryOperator) in the type IntStream is not applicable for the arguments (String, (int string, int number) ->

{})

I don't understand why it's expecting an IntBinaryOperator, and don't really know what that is. From the examples I have seen, I would expect to pass a string to an accumulator.

Any thoughts/suggestions are appreciated, also would like to know the "Java" way of converting an array down to a string.

Top answer
1 of 2
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2 of 2
1
What exactly would your expected output be here? Also please format that code.
🌐
Medium
medium.com › @AlexanderObregon › javas-arrays-deeptostring-method-explained-968769f5a570
Java’s Arrays.deepToString() Method Explained | Medium
December 28, 2024 - Whether it’s a 2D array of integers or a deeply nested structure of objects, deepToString() iterates through the array elements, adding brackets to distinguish levels of nesting. The recursion stops when it encounters a non-array element, which is then converted to its string representation.
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-string-array
Java String Array: Declaration, Initialization & Examples | DigitalOcean
August 3, 2022 - Second statement is true because when converted to String, their values are same and String class equals() method implementation check for values. For more details, please check String class API documentation. We can iterate over string array using java for loop or java foreach loop.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-program-to-convert-string-to-integer-array
Java Program to Convert String to Integer Array - GeeksforGeeks
In Java, we cannot directly perform numeric operations on a String representing numbers. To handle numeric values, we first need to convert the string into an integer array.
Published   July 23, 2025
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-string-array-to-string
Java String Array to String | DigitalOcean
August 3, 2022 - We can also create our own method to convert String array to String if we have some specific format requirements. Below is a simple program showing these methods in action and output produced. package com.journaldev.util; import java.util.Arrays; public class JavaStringArrayToString { public static void main(String[] args) { String[] strArr = new String[] { "1", "2", "3" }; String str = Arrays.toString(strArr); System.out.println("Java String array to String = " + str); str = convertStringArrayToString(strArr, ","); System.out.println("Convert Java String array to String = " + str); } private static String convertStringArrayToString(String[] strArr, String delimiter) { StringBuilder sb = new StringBuilder(); for (String str : strArr) sb.append(str).append(delimiter); return sb.substring(0, sb.length() - 1); } }