9.4(使用随机类Random)

package hello;

public class Random {
public static void  main(String[] args) {
	Random random1 = new Random(1000);
	for(int i = 0; i < 50; i++) {
		System.out.println(random1.nextInt(100));
	}
}
int random;
public Random(int newRandom) {
	random = newRandom;
}
int nextInt(int random) {
	return (int)(random * Math.random());
}
}

猜你喜欢

转载自blog.csdn.net/weixin_39596963/article/details/79505868