- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
How to convert a comma separated String into an ArrayList in Java?
To convert a comma separated String into an ArrayList
- Split the String into an array of Strings using the split() method.
- Now, convert the obtained String array to list using the asList() method of the Arrays class.
Example
import java.util.Arrays; import java.util.List; public class Sample { public static void main(String[] args) { String myString = "JavaFx,Java,WebGL,OpenCV"; String[] myArray = myString.split(","); System.out.println("Contents of the array ::"+Arrays.toString(myArray)); List <String> myList = Arrays.asList(myArray); } }
Output
Contents of the array ::[JavaFx, Java, WebGL, OpenCV]
- Related Articles
- Convert String into comma separated List in Java
- Convert a List of String to a comma separated String in Java
- Convert a Set of String to a comma separated String in Java
- Java Program to Convert a List of String to Comma Separated String
- How to use a comma-separated string in an `IN ()` in MySQL?
- How to convert comma separated text in div into separate lines with JavaScript?
- How to convert comma seperated java string to an array.
- Convert an ArrayList of String to a String array in Java
- How to split comma and semicolon separated string into a two-dimensional array in JavaScript ?
- Java Program to Convert the ArrayList into a string and vice versa
- How to sum a comma separated string (string with numbers) in MySQL?
- How to convert an ArrayList to String in Kotlin?
- How to create a comma separated string from a list of string in C#?
- Converting a comma separated string to separate arrays within an object JavaScript
- How to turn JavaScript array into the comma-separated list?

Advertisements