有人能解释为什么这会造成无限循环吗? hurcdata2中有大约30个straing值。我不明白这是什么问题。
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
public class Hurricanes2
{
public static void main(String[] args) throws IOException
{
int i = 0;
int hurricaneNumber = 0;
String hurricanes = "";
File fileName = new File("hurcdata2.txt");
Scanner inFile = new Scanner(fileName);
while (inFile.hasNext())
{
hurricaneNumber++;
}
}
}