class ZiggyTest{
public static void main(String[] args) {
String str = "aaaaaaaaabb";
String [] s = str.split("a{3}");
for(String x : s){
System.out.print(" : " + x);
}
}
}
The output of the above is : : : : bb
What exactly happens when the split() does a split but there is nothing in between the split as in the above example. Is the value (in the array) classed as null or an empty string or something else?
I was expecting the contents of the array to be {bb} because the rest of the string did not return anything in between the split.
I was really interested in why it is storing the null/empty string in the array rather than just storing the returned values i.e. bb.
Thanks
You may want to read up split on zero-width matches. Here are some examples. Give it a try.