Try something like
List<String> myList = new ArrayList<String>(Arrays.asList(s.split(",")));
Arrays.asListdocumentationString.splitdocumentationArrayList(Collection)constructor documentation
Demo:
String s = "lorem,ipsum,dolor,sit,amet";
List<String> myList = new ArrayList<String>(Arrays.asList(s.split(",")));
System.out.println(myList); // prints [lorem, ipsum, dolor, sit, amet]
This post has been rewritten as an article here.
Related Posts:
- convert string to arraylist
in java - Best way to convert an ArrayList to a string
- Best way to convert an ArrayList to a string
- Add String Array to ArrayList
- How do I convert a String to an int in Java?
- How to format strings in Java
- Java – Convert integer to string [duplicate]
- How to split a string in Java
- How to avoid “ConcurrentModificationException” while removing elements from `ArrayList` while iterating it? [duplicate]
- How do I compare strings in Java?
- When to use LinkedList over ArrayList in Java?
- How to convert a char to a String?
- How to convert/parse from String to char in java?
- Reverse a string in Java
- Convert list to array in Java [duplicate]
- Reverse a string in Java
- Java String Split by “|”
- Convert String to double in Java
- Java String new line
- Initialization of an ArrayList in one line
- How to avoid java.util.ConcurrentModificationException when iterating through and removing elements from an ArrayList
- How to check if a String contains another String in a case insensitive manner in Java?
- Java split string to array [duplicate]
- String concatenation: concat() vs “+” operator
- How to remove the last character from a string?
- Java string to date conversion
- How to replace � in a string
- Change date format in a Java string
- How to sort an ArrayList?
- What are all the escape characters?
- What’s the C++ version of Java’s ArrayList
- Converting String to “Character” array in Java
- Create ArrayList from array
- “Exception in thread “main” java.lang.IndexOutOfBoundsException: Index: 0, Size: 0″ with ArrayList?
- How to split a String by space
- Print ArrayList
- Print ArrayList
- String interpolation in Java 14 or 15
- How to make a deep copy of Java ArrayList
- How can I prevent java.lang.NumberFormatException: For input string: “N/A”?
- How to remove single character from a String
- Array ArrayList python equivalent
- Java ArrayList copy
- How to parse this string in Java?
- How to convert any Object to String?
- how to iterate in List
- > in java and set their values as we do in a normal int a[i][j] matrix type [duplicate]
- How to split a string in Java
- Illegal Escape Character “\”
- Can I multiply strings in Java to repeat sequences?
- What does regular expression \\s*,\\s* do?
- How to convert an ArrayList containing Integers to primitive int array?
- How to convert a Binary String to a base 10 integer in Java
- Left Hand Side of an Assignment must be a Variable CharAt
- How to capitalize the first letter of a String in Java?
- catDog string problem at Codingbat.com
- Java way to check if a string is palindrome
- Return string Input with parse.string
- What is the difference between String.subString() and String.subSequence()
- How do I apply the for-each loop to every character in a String?
- Java – removing first character of a string
- Java compressing Strings
- Explain the use of a bit vector for determining if all characters are unique
- Explain the use of a bit vector for determining if all characters are unique
- Print ArrayList
- Convert array of strings into a string in Java
- Why do I get an UnsupportedOperationException when trying to remove an element from a List?
- Sort a single String in Java
- HashSet vs. ArrayList
- Java ArrayList replace at specific index
- How to remove single character from a String
- How to remove single character from a String
- What is Java String interning?
- What is Java String interning?
- What is Java String interning?
- Why is there no String.Empty in Java?
- Java split string to array
- How can I create an Array of ArrayLists?
- Using Enum values as String literals
- What is the easiest/best/most correct way to iterate through the characters of a string in Java?
- How to create an 2D ArrayList in java?
- Error: cannot find symbol ArrayList
- int cannot be converted to string?
- How to check if my string is equal to null?
- what is Ljava.lang.String;@
- java howto ArrayList push, pop, shift, and unshift
- Convert String to int array in java
- Converting String Array to an Integer Array
- How to sort an array of objects in Java?
- How to sort an array of objects in Java?
- How to compress a String in Java?
- java.lang.NumberFormatException: empty String
- How to check if a String is numeric in Java
- How to replace a substring of a string
- Converting A String To Hexadecimal In Java
- Immutable class?
- How to get the last value of an ArrayList
- How to add an object to an ArrayList in Java
- Converting a string to an integer on Android
- Simple way to repeat a string
- Java end of file