/* Method: findName() */
/**
* Finds the name of the entry and sets it to the name variable.
*/
private void findName(String line){
end = line.indexOf(" ");
name = line.substring(0,end);
}
/* Method: findDecades() */
/**
* Finds the name of the entry and sets it to the name variable.
*/
private void findDecades(String line){
for(int i = 0; i<NDECADES; i++){
int start = end + 1;
end = line.indexOf(" ",start);
String decadeTemp = line.substring(start, end);
data[i] = Integer.parseInt(decadeTemp);
}
}
Line looks like the following:
Sam 58 69 99 131 168 236 278 380 467 408 466
When I run the code the first method runs fine but then it throws an error exception when it reaches the line:
String decadeTemp = line.substring(start, end);
edit:
the error that is throw is:
throw new StringIndexOutOfBoundsException(endIndex - beginIndex);