1.导包 :import java.util.Scanner;
2.创建Scanner类的对象 : Scanner scanner = new Scanner(System.in);
3.调用Scanner类中的方法
import java.util.Scanner; public class ScannerTest{ public static void main(String[] args){ //创建Scanner类的对象 : Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in); //调用Scanner类中的方法 System.out.println("请输入您的成绩"); int score = scanner.nextInt(); System.out.println("请输入您的姓名"); String name = scanner.next(); System.out.println("请输入您帅不帅(true/false)"); boolean handsome = scanner.nextBoolean(); System.out.println("score=" + score); System.out.println("name=" + name); System.out.println("handsome=" + handsome); } }