Java程序在编译时不断抛出错误

时间:2016-10-01 12:36:17

标签: java

EyeColour.java:27: error: cannot find symbol
    Scanner input = scanner(System.in);
                    ^
  symbol:   method scanner(InputStream)
  location: class EyeColour
1 error

我在尝试编译以下代码时遇到这个^^错误我是Java的新手,我无法在线找到解决方案,对不起,如果解决方案非常明显:

import java.util.Scanner;
class EyeColour // 
{
    public static void main (String[] param)
    {

        InputEye();
        System.exit(0);

     } // END main


    public static void InputEye()  
    {
        Scanner scanner = Scanner(System.in);
        System.out.println("What is your eye colour?");
        String EyeColour;
        EyeColour = scanner.nextLine();
        System.out.println("So your eyes are " + EyeColour + " are they? I like " + EyeColour);
        return;

    } // END InputEye  



} // END class EyeColour  

1 个答案:

答案 0 :(得分:3)

您错过了new关键字 试试这个:

Scanner scanner = new Scanner(System.in);