gpt4 book ai didi

java - 在方法中导入扫描仪类

转载 作者:行者123 更新时间:2023-12-01 08:05:43 25 4
gpt4 key购买 nike

我在学校有一项作业,我必须导入扫描仪并编写一个方法。我做错了什么?

    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: 找不到符号

最佳答案

print 仅接受一个 String 参数 - 将逗号移至 String

System.out.print("Your application date is" + month + " ," + year + "!");
^

关于java - 在方法中导入扫描仪类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21857862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com