09_API_Scanner

09_API_Scanner

 

 1.API

09_API_Scanner

 


 

2.API_Scanner

2.1功能 

09_API_Scanner

 

 2.2导包

09_API_Scanner

 

 2.3构造函数

09_API_Scanner

 

 2.4常用方法

09_API_Scanner

        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功能

09_API_Scanner

 

 3.2构造方法

09_API_Scanner

 

 3.3成员方法

09_API_Scanner

 

09_API_Scanner

        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());

09_API_Scanner

上一篇:WPF - 简单的UI框架


下一篇:C# 文件类总结 File、Directory、FileStream、StreamWriter、StreamReader