[英]This code gives me an incompatible types error. It says it requires a Scanner but found String. I don't understnd how I can fix it
public static void getBooks(){
int bookNum = 0;
bookFile = new File(args[0]);
Scanner input = new Scanner(bookFile);
while (input.hasNextLine()) {
bookNum += 1;
input = input.nextLine();
}
...
}
我需要它来增加书的数量,只要在下一行时有书要添加含义即可。
问题在这里:
input = input.nextLine();
两个input
s可能是两个单独的变量。 将此更改为:
String line = input.nextLine();
// use `line' here
此input = input.nextLine();
没有意义。 你想让我做什么? 只需运行input.nextLine()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.