java - ArrayIndexOutOfBoundsException / GUI -


i working on programm takes input file , stores information in array. then, there 5 methods adding, deleting, printing information, etc. have created embedded class gui. there 1 button each method.

the problem "addentry" method works fine when read information file, when try add information array individually, gives "arrayindexoutofboundsexception". happens through gui. if call method in main class works fine. add method:

public void addentry(string sur, string init, string telex) {     currentplace++;      setsurname(sur);     setinitial(init);     settelext(telex);      array[currentplace] = (new entry(getsurname(), getinitial(), gettelext())); } 

the variable currentplace field place of last element in array stored. entry class, contains 2 constructors (default , 1 3 fields) , get/set methods. moreover, if decrease currentplace 1, works lose last element of array.

you allocated not enough items in array. errormessage pretty obvious hint imo.

object[] o = new object[2]; o[2] = x;   <-- index out of bounds 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -