我在学校有这项任务,我必须导入扫描仪并编写方法。我做错了什么?
public static void main(String[] args)
{
applicationDate();
}
public static void applicationDate()
{
Scanner input = new Scanner(System.in);
System.out.println("On what day of the month you applied?");
int day = input.nextInt();
System.out.println("What is the name of the month in wich you applied?");
String month = input.nextLine();
System.out.println("During wich year you applied?");
int year = input.nextInt();
System.out.print("Your application date is" + month + " ", + year + "!");
}
编译东西时出现此错误, EX20.java:27:找不到符号
答案 0 :(得分:3)
print
只需要一个String
参数 - 在String
System.out.print("Your application date is" + month + " ," + year + "!");
^
答案 1 :(得分:2)
删除逗号并将其添加到双引号之间,如下所示。
System.out.print("Your application date is" + month + " ,"+ year + "!");
答案 2 :(得分:1)
首先将import java.util.Scanner;
添加到您的文件中。
由于缺少此行,您必须收到错误
error: cannot find symbol
Scanner input = new Scanner(System.in);
^
然后
从上一个print语句中删除额外的逗号。
System.out.print("Your application date is" + month + " ,"+ year + "!");