mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
用RandomUtil
This commit is contained in:
parent
1e7af4d7fc
commit
8e0a5e2029
@ -1362,10 +1362,9 @@ public class NumberUtil {
|
||||
throw new UtilException("Size is larger than range between begin and end!");
|
||||
}
|
||||
|
||||
Random ran = new Random();
|
||||
Set<Integer> set = new HashSet<>();
|
||||
Set<Integer> set = new HashSet<>(Math.max((int) (size / .75f) + 1, 16));
|
||||
while (set.size() < size) {
|
||||
set.add(begin + ran.nextInt(end - begin));
|
||||
set.add(begin + RandomUtil.randomInt(end - begin));
|
||||
}
|
||||
|
||||
return set.toArray(new Integer[size]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user