-2

I'm receiving this fantastic stack:

Exception in thread "AWT-EventQueue-0"
java.lang.ArrayIndexOutOfBoundsException: 0
at test.Visual.selection(Visual.java:156)
at test.Menu.actionPerformed(Menu.java:161)

Visual.java -- line 156 is 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 is 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);
    }
}
entpnerd
  • 10,049
  • 8
  • 47
  • 68
Mark Doe
  • 125
  • 2
  • 2
  • 9

1 Answers1

1

There are two problems going on here and it's not just the ArrayIndexOutOfBoundsException. For that immediate problem, based on the error message, your array is empty and your code is trying to find the first element at index 0, which it can't because empty arrays have no elements.

That being said, based on what I can see from the context of your problem, it looks like you are trying to read some data from your file via the String[] temp=map.file.reader(); line.

So, I would either fix that reader() function or the data it reads. Also, I would strongly encourage you to write some validation code for what you read from that function.

entpnerd
  • 10,049
  • 8
  • 47
  • 68