Java Experts ,
Please look into the below split command code and let me know why last two nulls are not captured.
String test = "1,O1,,,,0.0000,0.0000,,";
String[] splittest = test.split(",");
System.out.println("length -"+splittest.length);
for (String string : splittest) {
System.out.println("value"+string);
}
The result iam getting
length -7
value1
valueO1
value
value
value
value0.0000
value0.0000
surprisingly the length is 7 where as it should be 9 and also as you can see values after 0.0000 ie two last nulls are not coming . Lets say now if i change the string test "1,O1,,,,0.0000,0.0000,0,0"
String test = "1,O1,,,,0.0000,0.0000,0,0";
String[] splittest = test.split(",");
System.out.println("length -"+splittest.length);
for (String string : splittest) {
System.out.println("value"+string);
}
I am getting correctly
length -9
value1
valueO1
value
value
value
value0.0000
value0.0000
value0
value0
I don't think iam doing wrong . Is it a bug ? JAVA Version - jdk1.6.0_31