package com.pyk.teat;
import java.util.Random;
public class Test01 {
public static void main(String[] args) {
//Random类
Random r1=new Random(1000000L);
int a=r1.nextInt();
System.out.println(a);//多次运行发现出现的随机数是一样的
//Random()里面传入的long类型的数不一样,这样出现的随机数就会不一样
Random r2=new Random(System.currentTimeMillis());
int b=r2.nextInt();
System.out.println(b);
//利用空参构造器创建对象
Random r3=new Random();//表面是在调用无参数构造器,但是实际底层还是调用了带参构造器
System.out.println(r3.nextInt(10));//在0(包括)和指定值(不包括)之间均匀分布的int值
System.out.println(r3.nextDouble());//在0.0和1.0之间均匀分布的double值
}
}