Habeeb Hassan Syed wrote:spilt(",*") which takes care of a single , or multiple commas.
I hope you meant ",+", because ",*" matches any number of commas, including none at all. As a result, the empty string matches as well and you get an array with each single character, plus one empty match at the start (after all, any string starts with the empty string). Try it yourself:
I you want the delimiter to be , as well as space you can use split("[ ,]") also if you want to trim your strings and has a comma seperated delimiter you can use split(" *, *")
Even better is
split("\\s*,\\s*). The regular expression \s (the \ is escaped to be used in a
Java string) means any whitespace character. That is not just spaces but also line breaks.