I have a text file that's comma delimited. It contains 3 values per line ( firstname, lastname, age)
String s = "Joe,,23";
String[] delimitedArray = s.split(",");
the problem comes when there is a value that isn't entered, like in the example lastname is not there so when you use the split method and you check the string array's length it returns 2 instead of 3, which is totally understandable. However is there a way to make sure it will always have 3 elements in the array, even if one or more values are missing? I know you could
s.split(",",3);
but even if I try get the 3rd element it will say indexOutOfBounds (again, expected).
Any work around for this?