首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用java scanner

使用java scanner
EN

Stack Overflow用户
提问于 2020-08-24 09:55:51
回答 1查看 46关注 0票数 0

如果这看起来有点新奇,我很抱歉,但我知道我们都得从某个地方开始..它阻止了我将用户数据放在甜点之后,远远早于it...this是一个编辑问题

包扫描仪;导入java.util.Scanner;

使用扫描器的公共类{

代码语言:javascript
复制
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);
    
    
    
    
}

}

EN

回答 1

Stack Overflow用户

发布于 2020-08-24 10:01:34

年龄为整数,使用age = sc.nextInt();

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63553786

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档