Answers for "how to spilt the string with comma in jaav"

0

how to spilt the string with comma in jaav

String str = "dog, cat, bear, elephant, ..., giraffe";
List<String> elephantList = Arrays.asList(str.split(","));
//If you want to additionally get rid of whitespaces around items:
String[] elephantList = str.split("\\s*,\\s*");
Posted by: Guest on March-29-2022

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language