Java ——Scanner
本节重点思维导图
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); } }