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
答案 0 :(得分:3)
您错过了new
关键字
试试这个:
Scanner scanner = new Scanner(System.in);