如果这看起来有点新奇,我很抱歉,但我知道我们都得从某个地方开始..它阻止了我将用户数据放在甜点之后,远远早于it...this是一个编辑问题
包扫描仪;导入java.util.Scanner;
使用扫描器的公共类{
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
String userName;
int age;
String dessert;
System.out.println("Hi What is your name? ");
userName = sc.nextLine();
System.out.println ("How are you doing, " + userName + "?");
System.out.println ("What is you age, " + userName + "?");
age = sc.nextInt();
System.out.println ("Hello, " + userName + " you are " + age);
System.out.println ("ok, " + userName + " .Your are " + age + "." + " What is your favorite dessert?");
dessert = sc.nextLine();
System.out.println (" Hello, " + userName + "You are " + age + " and your favorite dessert is " + dessert);
}}
发布于 2020-08-24 10:01:34
年龄为整数,使用age = sc.nextInt();
https://stackoverflow.com/questions/63553786
复制相似问题