0

PROBLEM AND ERROR: Ok so I have a file that has 12 values that I'm reading in to the program and I'm trying to assign them to an array. My error that I'm receiving is as follows:

java.lang.ArrayIndexOutOfBoundsException: 0
at HeatIndex.main(HeatIndex.java:14)

CODE: Here is the code Which includes everything in the Main method:

public static void main(String args[]) throws IOException{
    //creating objects
    Scanner inFileTemp = new Scanner(new File("temp.txt"));
    Scanner inFileHum = new Scanner(new File("humidity.txt"));

    //creating variables and arrays
    double tempArray[] = {};
    double humArray[] = {};

    for(int i = 0; i < 12; i++){
        tempArray[i] = inFileTemp.nextDouble();
        humArray[i] = inFileHum.nextDouble();
    }
}

SOME THINGS I TRIED: If anybody could help or lead me in the right direction that would be fantastic! I realize it is probably a simple problem but here are some of the things I have tried changing:

So the file has 12 values I tried changing the terminator to 13 and 11 but I 
still received the same error.

I also tried:

Changing the counting variable from 0 to 1 and so on.

Any explanation or help is much appreciated.

0 Answers0