Split String to List java
How to Convert a String to ArrayList in Java?Converting String to ArrayList means each character of the string is added as a separator character element in the ArrayList. Example: Input: 0001 Output: 0 0 0 1 Input: Geeks Output: G e e k sWe can easily convert String to ArrayList in Java using the split() method and regular expression. Parameters:
Returns: An array of strings computed by splitting the given string. Throws: PatternSyntaxException if the provided regular expressions syntax is invalid. Approach:
Java
Output
G
e
e
k
s
Attention reader! Dont stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
Article Tags :
Java Java Programs
Java-ArrayList Java-Strings Practice Tags :
Java-Strings Java
Read Full Article
|