本节重点思维导图

 Java ——Scanner 随笔

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

 

import java.util.Scanner;//导包

public class Demo {

    public static void main(String[] args) {
        //Scanner是Java中输入的一个工具类
        Scanner scanner = new Scanner(System.in);//定义一个Scanner
        
        System.out.println("input your name:");
        String name = scanner.next();//输入字符串
        System.out.println(name);
        
        System.out.println("input your age:");
        int age = scanner.nextInt();//输入整型数字
        System.out.println(age);
        
        System.out.println("input your score:");
        float score = scanner.nextFloat();//输入浮点数
        System.out.println(score);
        
        System.out.println("input your gender:");
        String gender = scanner.next();
        System.out.println(gender);
    }
}

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄