When you split the above string using the given crieria(alpha numeric character at every 3rd position), it splits the String like this: "aaa", "aaa","aaa","bb"
and stores it in array at 0,1,2,3 index so the length is 4.
When regex is "o" an empty string is created when "oo" is found in boo. Why is an empty string not found when the String splits on the last two "oo"?? In other words y is the array length 3 and not 4 with two empty strings?
When you call the split function with only one argument ,then it assumes that the second argument of the split function is zero. And when the second argument is zero then the pattern will be applied as many times as possible, the array can have any length, and trailing empty strings will be discarded. This is the reason why you are not seeing the trailing empty strings.