java Math.random()
Math.random()是令系统随机选取大于等于 0.0 且小于 1.0 的伪随机 double 值
函数返回 min(包含)~ max(不包含)之间的数字:
Math.floor(Math.random() * (max - min) ) + min;
函数返回 min(包含)~ max(包含)之间的数字
Math.floor(Math.random() * (max - min + 1) ) + min;
Math.random()是令系统随机选取大于等于 0.0 且小于 1.0 的伪随机 double 值
函数返回 min(包含)~ max(不包含)之间的数字:
Math.floor(Math.random() * (max - min) ) + min;
函数返回 min(包含)~ max(包含)之间的数字
Math.floor(Math.random() * (max - min + 1) ) + min;