I don\'t get it why i in fillArray method ends up being equal to 10 even though the array score is filled only up to index 9>
While others have already explained in detail , to eliminate confusion you could modify your code to something like :
double next = keyboard.nextDouble();
int i = 0;
int current_i = i;
for( i = 0; ( next >= 0 && i < a.length ); i++ )
{
current_i = i;
a[i] = next;
next = keyboard.nextDouble();
}
return current_i;
instead of
double next = keyboard.nextDouble();
int i = 0;
for(i = 0;(next>=0 && i