[英]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.