扫描仪输入新的Scaner(doc); < ----------错误;预期

时间:2011-03-14 13:30:23

标签: java compiler-errors

我正在尝试编译,但我似乎收到一条错误,指出我在;的行上错过了;。我也查看了代码,自己也看不到错误。我希望你能指出我正确的方向:)

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);
    }
 }
}

2 个答案:

答案 0 :(得分:5)

您错过了=

Scanner input = new Scanner(doc);

答案 1 :(得分:0)

Scanner input = new Scanner(doc);
“”=“缺失,Scanner拼错了;将可见性doc更改为全局