
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 String into comma separated List in Java
At first, set a list with string values −
List<String> myList = new ArrayList<>( Arrays.asList("One", "Two", "Three", "Four"));
Now, use String.join() to set them as a comma separated list −
String str = String.join(", ", myList);
Example
Following is the program to convert string into comma separated List 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 Questions & Answers
- Convert a List of String to a comma separated String in Java
- How to convert a comma separated String into an ArrayList in Java?
- Java Program to Convert a List of String to Comma Separated String
- Convert a Set of String to a comma separated String in Java
- How to turn JavaScript array into the comma-separated list?
- How to convert comma separated text in div into separate lines with JavaScript?
- Display MySQL Results as comma separated list?
- How to create a comma separated string from a list of string in C#?
- How would you make a comma-separated string from a list in Python?
- Regex to find string and next character in a comma separated list - MySQL?
- How to split comma and semicolon separated string into a two-dimensional array in JavaScript ?
- Convert Short into String in Java
- Remove specific word in a comma separated string with MySQL
- How to sum a comma separated string (string with numbers) in MySQL?
- Check if value exists in a comma separated list in MySQL?
Advertisements