System.out.print("random1 ==");
//自定义种子为100
Random random1 = new Random(100);
for (int i = 0; i < 10; i++) {
int s=random1.nextInt(200);
System.out.print(+ s+" ");
}
System.out.println();
System.out.print("random2 ==");
//自定义种子为100
Random random2 = new Random(100);
for (int i = 0; i < 10; i++) {
int s=random2.nextInt(200);
System.out.print(+ s+" ");
}
System.out.println();
System.out.print("random3 ==");
//随机种子
Random random3 = new Random();
for (int i = 0; i < 10; i++) {
int s=random3.nextInt(200);
System.out.print(+ s+" ");
}
System.out.println();
System.out.print("random4 ==");
//随机种子
Random random4 = new Random();
for (int i = 0; i < 10; i++) {
int s=random4.nextInt(200);
System.out.print(+ s+" ");
}
自己观察自定义种子 每次输出的 随机数都是一样