更新时间:2021-12-29 08:22:14
在应用程序启动时构造一个Random对象:
Construct a Random object at application startup:
Random random = new Random();
然后使用 Random.nextInt(int):
int randomNumber = random.nextInt(max + 1 - min) + min;
请注意,下限和下限均包含在内。
Note that the both lower and upper limits are inclusive.