arrays - What does java.lang.ArrayIndexOutOfBoundsException mean? -
i new java , today started work on arrays , i'm lost. trying put values in array i'm getting error java.lang.arrayindexoutofboundsexception
.
here have done far.
int n=6; int[]a= new int [1]; for(i=0;i<n;i++){ a[i]=keyboard.nextint(); }
java.lang.arrayindexoutofboundsexception means trying access array index doesn't exist.
the problem array of size one.however, going through loop 6 times. can either make n equal one, or increase size of array.
Comments
Post a Comment