*9.4(使用 Random类)编写一个程序,创建种子是 1000 的 Random 对象,然后使用 nextInt(100) 方法显示 0 到 100 之间的 50 个随机整数。 *9.4(Using the random class)Write a program to create a random object with a seed of 1000, and then use the nextint (100) method to display 50 random integers between 0 and 100.
参考代码:
package chapter09;import java.util.Random;publicclassCode_04{
publicstaticvoidmain(String[] args){
Random random =newRandom(1000);for(int i =0, n =0; i <50; i++, n++){
if(n %10==0)
System.out.println("");
System.out.print(random.nextInt(100)+" ");}}}
结果显示:
87357624924941456450795972833675462234122718929342494235763205295873199187929155584719558877738
Process finished with exit code 0