所以我在这里的代码是:
public int getCount()
{
Scanner s1 = new Scanner(line);
int count=0;
while(s1.hasNextInt());
{
int x = s1.nextInt();
count++;
}
return count;
}
我不明白为什么在使用 .nextInt(); 时会出现无限循环;并遵循我所有的笔记。
如果你们中的任何人可以提供帮助,我将不胜感激。
非常感谢!