How to convert string to list of characters using regular expression in Java

1 Answer

0 votes
import java.util.List;
import java.util.Arrays;

public class MyClass {
    public static void main(String args[]) {
        String s = "java c++ c php python c#";
 
        List<String> lst = Arrays.asList(s.split("\\s*"));
 
        System.out.println(lst);
    }
}
 

 
/*
run:

[j, a, v, a, , c, +, +, , c, , p, h, p, , p, y, t, h, o, n, , c, #]

*/

 



answered Jun 25, 2019 by avibootz
...