Quoting from Java docs: https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String)
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.
This means that the empty strings are only included when there is at least one non-empty string that succeeds them.
import java.util.Arrays;
public class StringQ{
public static void main(String args[]){
String first = "0..";
System.out.println(Arrays.asList(first.split("\\.")));
// [0]
String second = "..0";
System.out.println(Arrays.asList(second.split("\\.")));
// [, , 0]
String third = "...0..0...";
System.out.println(Arrays.asList(third.split("\\.")));
// [, , , 0, , 0]
}
}