我正在尝试编译,但我似乎收到一条错误,指出我在;
的行上错过了;
。我也查看了代码,自己也看不到错误。我希望你能指出我正确的方向:)
import java.io.*;
import java.util.*;
public class marks
{
private String asses;
private int mark;
public marks()
{
}
public void createFile() throws Exception
{
File doc;
doc = new File ("marks.txt");
if(!doc.exists()){
doc.createNewFile();
System.out.println("A New File Has been Created");
}
else {
System.out.println ("File Already Exists");
}
}
public void enterMarks()
{
Scanner input new Scaner(doc); <---------- Error ; expected
while (input.hasNext()){
String asses = input.next();
int mark = input.nextInt();
System.out.println( asses +" "+ mark);
}
}
}
答案 0 :(得分:5)
您错过了=
:
Scanner input = new Scanner(doc);
答案 1 :(得分:0)
Scanner input = new Scanner(doc);
“”=“缺失,Scanner
拼错了;将可见性doc
更改为全局