The API documentation of String method spilt() states:
Java API documentation wrote:public String split(String regex)
This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array.
So when you call "aaaaXXXaaXXXaaaa".split("a"), the resultant array excludes the trailing empty Strings. It doesn't exclude the leading empty String values.
This explains why "aaaaaaaaaaaaaaaa".split("a") returns .