第2章 Java基础语法—Scanner类介绍
import java.util.Scanner;
class ScannerTest{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("请输入你的姓名:");
String name = scan.next();
System.out.println("请输入你的芳龄:");
int age = scan.nextInt();
System.out.println("请输入你的体重:");
double weight = scan.nextDouble();
System.out.println("你是否相中我了呢?(true/false)");
boolean isLove = scan.nextBoolean();
System.out.println("请输入你的性别:(男/女)");
String gender = scan.next();
char genderChar = gender.charAt(0);
}
}