public static void main(String[] args){
String[] arr = "value1:value2::value3".split(":");
for(String elm:arr){
System.out.println("'"+elm+"',");
}
System.out.println(arr.length);
}
prints
'value1',
'value2',
'',
'value3',
4
Which is exactly what you want. Your mistake is somewhere else...