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();
}
...
}我需要它来增加书籍的数量,只要有书要增加的意思,而有下一行。
发布于 2014-03-15 19:33:30
问题在于:
input = input.nextLine();这两个input可能是两个独立的变量。将此更改为以下内容:
String line = input.nextLine();
// use `line' here发布于 2014-03-15 19:33:40
这个input = input.nextLine();没有任何意义。你想做什么?只需运行input.nextLine()
https://stackoverflow.com/questions/22428682
复制相似问题