I'm trying to run through a file and add each string in the file to a string array.
My code yields the error
"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at StudentLAM.main(StudentLAM.java:14)"
Why doesn't this work? Note: I cannot use ArrayList.
My error-yielding code:
private Scanner index;
int cell = 0;
public String[] rawData = new String[count]; //the int count has been set to equal the number of strings in the file; I didn't include its instantiation method
while (index.hasNext()) {
rawData[cell] = index.next();
cell++;
}
for (int x = 0; x <= count; x++) {
System.out.println(rawData[x]);
}
I omitted a lot of code for brevity's sake.