I am writing a program where I wa开发者_如何学Gont to split a string separated by comma. My problem is a user can pass or input the string to the program like this:
Hello,,hey,123
So, is there a way that I can add a space between the hello
and hey
before I append it to a arraylist. Also my delimiter is ignoring the double ,,
and just going to the next word why is that ?
String s = "Hello,,hey,123";
String[] tokens = s.split(",", -1);
精彩评论