如代码中,为何for循环中生成的10次随机数a,b是每次不同的,但是我每次运行,产生的c和d却是固定不变的?
我不是要不同,我是把for中的10次循环当做运行10次(这样理解我不知道对不对),它第1次和第2次(每次是这个意思)都不一样,但是每次运行后c和d 是一样的 。
import java.util.Random;
public class Test00 {
public static void main(String[] args) {
Random rd = new Random(99);
Random rt = new Random(99);
int a;
int b;
for(int i=0;i<10;i++) {
a = rd.nextInt(55);
b = rt.nextInt(55);
System.out.println("第"+i+"次"+a+" "+b);
}
int c = rd.nextInt(55);
int d = rt.nextInt(55);
System.out.println(c+" "+d);
}
}
```运行结果
第0次47 47
第1次43 43
第2次34 34
第3次46 46
第4次0 0
第5次37 37
第6次29 29
第7次11 11
第8次45 45
第9次44 44
33 33 //点击10次,此处依旧是33 33