1.API
2.API_Scanner
2.1功能
2.2导包
2.3构造函数
2.4常用方法
Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); System.out.println("a:" + a); String str = scanner.next(); System.out.println("str:" + str); /*99 a:99 淦 str:淦*/
3.API_Random
3.1功能
3.2构造方法
3.3成员方法
Random random = new Random(); //获取随机整数,整个整数范围 System.out.println(random.nextInt()); //获取随机整数,[0,n] System.out.println(random.nextInt(10)); //获取随机整数,[min,max) random(max-min)+min System.out.println("=======获取4~8间的整数==================="); for (int i = 0; i < 10; i++) { System.out.println(random.nextInt(4)+4); } //获取随机boolean值 System.out.println(random.nextBoolean()); //获取随机double值(0~1) System.out.println(random.nextDouble()); //获取随机float值(0~1) System.out.println(random.nextFloat());