doc

说明

RandomUtil主要针对JDK中Random对象做封装,严格来说,Java产生的随机数都是伪随机数,因此Hutool封装后产生的随机结果也是伪随机结果。不过这种随机结果对于大多数情况已经够用。

使用

例如我们想产生一个[10, 100)的随机数,则:

int c = RandomUtil.randomInt(10, 100);
byte[] c = RandomUtil.randomBytes(10);
Set<Integer> set = RandomUtil.randomEleSet(CollUtil.newArrayList(1, 2, 3, 4, 5, 6), 2);