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

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -