标签:
import java.util.Random; public class RandomDemo01 { public static void main(String[] args) { Random r1 = new Random(); for (int x = 0; x < 10; x++) { int num1 = r1.nextInt(100) + 1; System.out.print(num1 + ","); } System.out.println(); System.out.println("---------------------------"); //给定种子后,每次的得到的随机数都是一样的。 Random r2 = new Random(1111); for (int x = 0; x < 10; x++) { int num2 = r2.nextInt(100) + 1; System.out.print(num2 + ","); } } }
输出结果:
标签:
原文地址:http://www.cnblogs.com/yangyquin/p/5023979.html