In Java 8 you can use String.join() like following:

Collection<String> elements = ....;
String result = String.join(", ", elements);
Answer from Ali Dehghani on Stack Overflow
๐ŸŒ
How to do in Java
howtodoinjava.com โ€บ home โ€บ java array โ€บ join string array in java with comma or any separator
Join String Array in Java with Comma or Any Separator
3 weeks ago - The shortest way to join a String array in Java is String.join(โ€œ,โ€, array), which returns one String with the separator between every two elements and none after the last. The same method accepts a List or any other Iterable of strings.
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ java โ€บ standard library โ€บ java โ€บ lang โ€บ string โ€บ join()
Java String join() - Concatenate Strings | Vultr Docs
December 27, 2024 - Explore various practical scenarios ... edge cases. Understand the signature of the method. Use the join() method to concatenate strings with a comma separator....
Discussions

Convert String[] to comma separated string in java - Stack Overflow
String list = "'" + StringUtils.join(names,"','") + "'"; this would give you the Single quotes needed by the SQL request. 2016-02-26T04:22:30.847Z+00:00 ... Nice and simple: but java8 required! More on stackoverflow.com
๐ŸŒ stackoverflow.com
java - The most sophisticated way for creating comma-separated Strings from a Collection/Array/List? - Stack Overflow
During my work with databases I noticed that I write query strings and in this strings I have to put several restrictions in the where-clause from a list/array/collection. Should look like this: s... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Avoiding printing the last comma of an arraylist
If you're using Java 8 or above, you can achieve it like this:- Arrays.stream(array).collect(Collectors.joining(", ")); More on reddit.com
๐ŸŒ r/javahelp
10
4
July 14, 2020
How do I convert an array to a string with commas in JavaScript
...you get a better, more thorough explanation here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join More on reddit.com
๐ŸŒ r/JavaScriptTips
1
4
April 13, 2023
๐ŸŒ
Mkyong
mkyong.com โ€บ home โ€บ java โ€บ java โ€“ how to join list string with commas
Java โ€“ How to join List String with commas | mkyong.com
November 29, 2018 - In Java, we can use String.join(",", list) to join a List String with commas. 1.1 String.join ยท JavaStringExample1.java ยท package com.mkyong; import java.util.Arrays; import java.util.List; public class JavaStringExample1 { public static void ...
๐ŸŒ
StackHowTo
stackhowto.com โ€บ home โ€บ java โ€บ how to join list string with commas in java
How To Join List String With Commas In Java - StackHowTo
October 9, 2021 - Since Java 8, the String class has a static method called join(). This method takes the separator and the list of strings, as shown in the example bellow: List names = Arrays.asList("Alex", "Jean", "Emily"); String str = String.join(", ", names); ...
Find elsewhere
๐ŸŒ
javaspring
javaspring.net โ€บ blog โ€บ join-array-string-java
Joining Array Strings in Java: A Comprehensive Guide โ€” javaspring.net
For each element, if it's not the first element, we add a comma and a space before appending the element to the result string. Using StringBuilder is more efficient than using the + operator in a loop because String objects in Java are immutable.
๐ŸŒ
Baeldung
baeldung.com โ€บ home โ€บ java โ€บ java string โ€บ convert a list to a comma-separated string
Convert a List to a Comma-Separated String | Baeldung
July 2, 2025 - Letโ€™s take the following list ... utilities for String processing and provides the conversion method join(): String commaSeparatedString = String.join(",", arraysAsList); assertThat(commaSeparatedString).isEqualTo("ONE,T...
๐ŸŒ
Blogger
javarevisited.blogspot.com โ€บ 2016 โ€บ 03 โ€บ how-to-convert-array-to-comma-separated-string-in-java.html
How to Convert an Array to Comma Separated String in Java - Example Tutorial
June 22, 2025 - The simplest way to convert an array to comma separated String is to create a StringBuilder, iterate through the array, and add each element of the array into StringBuilder after appending the comma.
๐ŸŒ
BeginnersBook
beginnersbook.com โ€บ 2017 โ€บ 10 โ€บ java-string-join-method
Java String join() method
June 4, 2024 - import java.util.Arrays; import ... System.out.println(result); // Output: "Cricket", "Hockey", "Tennis" } } In the following example, we are using String.join() method with a variable number of string arguments....
๐ŸŒ
Medium
medium.com โ€บ 360learntocode โ€บ how-to-create-a-list-of-string-to-comma-separated-string-055dc0ec9ed4
How to Create a List of String to Comma Separated String | by kumar chapagain | 360learntocode | Medium
March 10, 2025 - 1. In Java 8 and later: Using String.join() method. import java.util.Arrays; import java.util.List; public class JavaStringJoin { public static void main(String[] args) { List <String> stringList = Arrays.asList("apple","banana","grapes"); String ...
๐ŸŒ
Dirask
dirask.com โ€บ questions โ€บ Java-convert-Array-to-comma-separated-String-D9OP0j
โค ๐Ÿ’ป Java - convert Array to comma separated String - Dirask
Quick solution with java 8 String.join method: // Java 8 String.join(",", users); If we don't have java 8, we can use Guava Joiner, quick example: // Guava Joiner Joiner.on(",").join(users) public class StringJoinerExample { public static void ...
๐ŸŒ
Java67
java67.com โ€บ 2016 โ€บ 08 โ€บ java-8-stringjoiner-example-how-to-join-String.html
Java 8 StringJoiner Example - How to join multiple Strings with delimiter in Java? | Java67
The java.util.StringJoiner can be used to join any number of arbitrary String, a list of String, or an array of String in Java. You can choose any delimiter to join String like comma, pipe, colon, or semi-colon.
๐ŸŒ
iO Flood
ioflood.com โ€บ blog โ€บ string-join-java
Using String.join Method in Java: Your Ultimate Guide
March 11, 2024 - The String.join() method in Java is a simple and effective way to concatenate, or join, strings. This method takes in a delimiter and an array of strings, and returns a single string that has all the strings joined with the specified delimiter.
๐ŸŒ
DEV Community
dev.to โ€บ satyam_gupta_0d1ff2152dcc โ€บ master-the-java-string-join-method-a-2025-guide-with-examples-best-practices-2oem
Master the Java String join() Method: A 2025 Guide with Examples & Best Practices - DEV Community
November 6, 2025 - It can be an array of strings (String[]) or any data structure that implements Iterable, which is basically most collections like List, Set, etc. How to Use String.join(): From Basic to Boss Mode Enough theory. Let's see this beauty in action. Example 1: The Classic Comma-Separated List This is the most common use case, and it's where join() shines. java import java.util.Arrays; import java.util.List; public class JoinDemo { public static void main(String[] args) { List<String> languages = Arrays.asList("Java", "Python", "JavaScript", "Golang"); // The old, clunky way (we've all been there) // ...
๐ŸŒ
Medium
medium.com โ€บ @AlexanderObregon โ€บ turning-a-java-list-into-a-comma-separated-string-efc1b6c44d1b
Turning a Java List into a Comma-Separated String | Medium
June 20, 2025 - Java includes a built-in method that handles the job of joining strings with punctuation or spacing between them. Itโ€™s part of the String class and gives you a way to combine a collection of strings using a delimiter you provide. This helps reduce boilerplate code, and the output is clean by default. You pass in the delimiter, give it a list or array of strings, and it returns the finished result.
๐ŸŒ
Blogger
javarevisited.blogspot.com โ€บ 2016 โ€บ 06 โ€บ 10-examples-of-joining-string-in-java-8.html
10 Examples of Joining String in Java - String.join vs StringJoiner
May 11, 2023 - You need to iterate through an array or list and then use a StringBuilder to append a comma after each element and finally to remove the last comma because you don't want a comma after the last element.
๐ŸŒ
Dot Net Perls
dotnetperls.com โ€บ join-java
Java - String.join Method - Dot Net Perls
January 25, 2024 - String.join is versatile. We don't need to pass it an array of Stringsโ€”it can make its own array from separate arguments. Here We pass the delimiter (a comma) and three values (value1, value2 and value3).
๐ŸŒ
Medium
medium.com โ€บ @alxkm โ€บ converting-a-list-of-strings-to-a-comma-separated-string-in-java-multiple-approaches-ebb86745c889
Java Interview: Converting a List of Strings to a Comma-Separated String in Java: Multiple Approaches | by Alex Klimenko | Medium
August 9, 2025 - Can easily add filtering or transformation before joining. ... StringBuilder sb = new StringBuilder(); for (int i = 0; i < names.size(); i++) { sb.append(names.get(i)); if (i < names.size() - 1) { sb.append(","); } } String result = sb.toString(); System.out.println(result); // Output: Alice,Bob,Charlie ยท Works in all Java versions.