Is there any built-in method in Java which allows us to convert comma separated String to some container (e.g array, List or Vector)? Or do I need to write custom code for t
You can do it as follows.
This removes white space and split by comma where you do not need to worry about white spaces.
String myString= "A, B, C, D"; //Remove whitespace and split by comma List finalString= Arrays.asList(myString.split("\\s*,\\s*")); System.out.println(finalString);