I do not understand the output of this code:
public class StringDemo{
public static void main(String args[]) {
String blank = \"\";
The API for the split method states that "If the expression does not match any part of the input then the resulting array has just one element, namely this string."
So, as the String blank doesn't contain a ",", a String[] with one element (i.e. blank itself) is returned.
For the String comma, "nothing" is left of the original string thus an empty array is returned.
This seems to be the best solution if you want to process the returned result, e. g.
String[] splits = aString.split(",");
for(String split: splits) {
// do something
}