- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Convert a List of String to a comma separated String in Java
At first, let’s say the following is our List of String −
List<String> myList = new ArrayList<>(Arrays.asList("One", "Two", "Three", "Four"));
Now, convert this to a comma separated string using String.join()
String str = String.join(", ", myList);
Example
Following is the program to convert List of String to a comma separated String in Java −
import java.util.*; public class Demo { public static void main(String args[]) { List<String> myList = new ArrayList<>(Arrays.asList("One", "Two", "Three", "Four")); System.out.println("List = " + myList); // comma separated String str = String.join(", ", myList); System.out.println("String (Comma Separated) = " + str); } }
Output
List = [One, Two, Three, Four] Comma separated String: One, Two, Three, Four
- Related Articles
- Java Program to Convert a List of String to Comma Separated String
- Convert String into comma separated List in Java
- Convert a Set of String to a comma separated String in Java
- Python program to convert list of string to comma separated string
- How to convert a comma separated String into an ArrayList in Java?
- How to create a comma separated string from a list of string in C#?
- Swift Program to Convert an Set of String to Comma Separated String
- Regex to find string and next character in a comma separated list - MySQL?
- How would you make a comma-separated string from a list in Python?
- How to sum a comma separated string (string with numbers) in MySQL?
- Convert a String to a List of Characters in Java
- Remove specific word in a comma separated string with MySQL
- How to use a comma-separated string in an `IN ()` in MySQL?
- MySQL query to get a single value from position of comma-separated string?
- How to convert comma seperated java string to an array.

Advertisements