📜  随机java代码示例

📅  最后修改于: 2022-03-11 14:52:40.493000             🧑  作者: Mango

代码示例5
import java.util.Random;
//If there is a need to reproduce the same sequence of random numbers, 
//we have to specify a seed to the constructor, like 100000
Random random = new Random(100000);    //using a seed
System.out.println(random.nextInt(5)); // print one random 0, 1, 2, 3, 4
System.out.println(random.nextInt(5));