Array index out of bounds error when using "."
I'm trying to get this bit of code to work when getting someones date of
birth and having to split it up in dd/mm/yyyy and using "." as the thing
that separates day from month and month from year. I managed to get it to
work for other characters such as "/", " ", "-". When i try to use "." i
get an array index out of bounds exception error.
if(input.contains("."))
{
String[] tokens = input.split(".");
day = Integer.parseInt(tokens[0]);
intMonth = Integer.parseInt(tokens[1]);
year = Integer.parseInt(tokens[2]);
}
Variables are declared above correctly (Well i assume so). As they work
with other cases. If not clear feel free to ask any questions, and thanks
in advance.
No comments:
Post a Comment