I have a problem in my Java program. I have a while loop which the program completely skips. I am sure that it skips the while-loop, as I have tested by trying to print out a sentence inside the while loop, which is not executed (neither is the rest of the loop). I don't get an error when i compile or run the program, and I really can't see what's wrong. If anybody could help me, that would be great. I have a while loop extremely similar to this which runs as expected, therefore I find it strange that this one doesn't work.
I will only write the while loop, since my program is very long. This while loop is inside a method (which only contains this loop). (I use easyIO which is similar to Scanner, only a less complex version)
int i = 0;
In file = (infile); //Infile is declared earlier in the program
int [][] array2D = new int [unique][unique];
String word1 = file.inWord();
while (file.hasNext()) {
String word2 = file.next();
word1 = word2;
}
hasNext()actually works. Hard-to-find bugs are always in code you're 100% absolutely positive can't be the problem.file.hasNext() == false. There's probably some issue in the filename you're using or something