I’m working on condensing my code. Right now, I’ve created 6 file scanners that each read from a separate file (questions1.txt, questions2.txt…). I’ve attempted to instead use an array of file scanners like so:
Scanner[] file = new Scanner[6];
for(int i = 0; i > file.length; i++) {
file[i] = new Scanner(new File("questions" + i+1 + ".txt"));
}
However, when I try to add the first line from a file to a string, it comes back as null:
inLine = file[0].nextLine();
Is what I am attempting possible, or does my code have to be revised?
Your for loop never gets executed, because
should be