Try something like
List<String> myList = new ArrayList<String>(Arrays.asList(s.split(",")));
Arrays.asList
documentationString.split
documentationArrayList(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 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?
- Convert list to array in Java [duplicate]
- Java String Split by “|”
- Convert String to double in Java
- Initialization of an ArrayList in one line
- How to avoid java.util.ConcurrentModificationException when iterating through and removing elements from an ArrayList
- Java string to date conversion
- How to sort an ArrayList?
- What are all the escape characters?
- 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 to remove single character from a String
- 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]
- Illegal Escape Character “\”
- Can I multiply strings in Java to repeat sequences?
- What does regular expression \\s*,\\s* do?
- 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()
- Java compressing Strings
- 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?
- 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?
- Why is there no String.Empty in Java?
- Java split string to array
- Using Enum values as String literals
- What is the easiest/best/most correct way to iterate through the characters of a string 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;@
- Convert String to int array in java
- Converting String Array to an Integer Array
- How to sort an array of objects in Java?
- java.lang.NumberFormatException: empty String
- 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: how to initialize String[]?
- Regular Expressions on Punctuation
- Incompatible types List of List and ArrayList of ArrayList
- How to extract a substring using regex
- difference between equals() and hashCode()
- Java String to SHA1
- Replace a character at a specific index in a string?
- Determine if a String is an Integer in Java [duplicate]
- How can I remove a substring from a given String?
- Java get String CompareTo as a comparator object
- How to use regex in String.contains() method in Java
- How to swap String characters in Java?
- Size has private access in ArrayList
- Get an OutputStream into a String
- Difference between string object and string literal
- How to write a test class to test my code?
- Java ArrayList of Doubles
- java: use StringBuilder to insert at the beginning
- How to create a Multidimensional ArrayList in Java?
- How do I get the last character of a string?
- Cannot invoke toString() on the primitive type int
- How to compare character ignoring case in primitive types
- What is the difference between ArrayList.clear() and ArrayList.removeAll()?
- Append a single character to a string or char array in java?
- String is immutable. What exactly is the meaning?
- Occurrences of substring in a string
- Quotation marks inside a string
- How Do I Implement an Insertion Sort Method for A Generic ArrayList?
- toring and Retrieving ArrayList values from hashmap
- return an ArrayList method
- Fastest way to put contents of Set
to a single String with words separated by a whitespace? - How to know if a given string is substring from another string in Java