Java: How to split a String into an ArrayList
Here are a few ways to split (or convert, or parse) a string of comma separated values:
input = "aaa,bbb,ccc";
// To array
String[] arr = input.split(",");
// To fixed-size list
List<String> l = Arrays.asList(input.split(","));
// To ArrayList
List<String> l2 = new ArrayList<>(Arrays.asList(input.split(",")));
Comments
Be the first to comment!