import java.util.Scanner;
public class endOffile{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int i = 1;
do
{
String s = sc.nextLine();
System.out.println(i+" "+s);
i++;
}
while(true);
}
}
当我运行该程序时,它会显示所需的结果,但显示运行时错误,提示:
“线程“主”中的异常” java.util.NoSuchElementException:
在endOffile.main(endOffile.java:9)的java.util.Scanner.nextLine(Scanner.java:1540)处找不到行”