random随机数

公式:假设你要产生5到10之间的随机数,可以用下面方法:
int Min = 5;
int Max = 10;
int result = Min + (int)(Math.random() * ((Max - Min) + 1));

例如:
生成5-26之间的随机数,包括26
int randNum = rand.nextInt(22)+5;

原文地址:https://www.cnblogs.com/gwxppg/p/11209331.html