indexoutofboundsexception - Can you help fix this java.lang.ArrayIndexOutOfBoundsException: 0? -


i'm receiving fantastic stack:

exception in thread "awt-eventqueue-0" java.lang.arrayindexoutofboundsexception: 0 @ test.visual.selection(visual.java:156) @ test.menu.actionperformed(menu.java:161) 

visual.java -- line 156 while statement

vidergrille(); decochage(); string[] temp=map.file.reader(); int index=map.sudoku.random(0,temp.length); switch(levelofdifficulty){     case 1:         while(!(integer.parseint(temp[index].substring(85,temp[index].length()))<=5000)){             index=map.sudoku.random(0,temp.length);         }         break; 

menu.java -- line 161 map.supanel

else if(evt.getsource()==m123){     try {         map.supanel.selection(1);     } catch (ioexception ex) {         logger.getlogger(menu.class.getname()).log(level.severe, null, ex);     } } 

there 2 problems going on here , it's not arrayindexoutofboundsexception. immediate problem, based on error message, array empty , code trying find first element @ index 0, can't because empty arrays have no elements.

that being said, based on can see context of problem, looks trying read data file via string[] temp=map.file.reader(); line.

so, either fix reader() function or data reads. also, encourage write validation code read function.


Comments