Java Convert ArrayList to Comma Separated String
In this Java core tutorial we learn how to convert a java.util.ArrayList object to a comma separated String in Java programming language.
How to convert ArrayList to Comma Separated String in Java
In Java, with a given ArrayList object we can use the String.join(CharSequence delimiter, Iterable<? extends CharSequence> elements) static method to convert it to a comma separated String value as the following example Java code.
ConvertArrayListToCommaSeparatedStringExample1.java
import java.util.ArrayList;
import java.util.List;
public class ConvertArrayListToCommaSeparatedStringExample1 {
public static void main(String... args) {
List<String> arrayList = new ArrayList<>();
arrayList.add("Java");
arrayList.add("Kotlin");
arrayList.add("Groovy");
String commaSeparatedString = String.join(",", arrayList);
System.out.println(commaSeparatedString);
}
}
Java,Kotlin,Groovy
Happy Coding 😊
Related Articles
Java Convert ArrayList to String
Java Convert ArrayList to Array
Java Convert ArrayList to HashSet
Java Convert ArrayList to LinkedList
Java Create New Array with Class Type and Length
Java Create ArrayList using List Interface
Java Get Index of Minimum Value in ArrayList
How to use Java ArrayList with Examples
Java Convert Array to ArrayList
Java Insert Element to ArrayList at Specified Index
Java Get Minimum Value in ArrayList
How to Traverse ArrayList using Iterator in Java
How to Traverse ArrayList using for each loop in Java