程序包 dev.utils.common
类 RandomUtils
java.lang.Object
dev.utils.common.RandomUtils
detail: 随机工具类
- 作者:
- Ttt
-
方法概要
修饰符和类型方法说明static double[]doubles(int streamSize, double randomNumberOrigin, double randomNumberBound) 获取随机 double[]static StringgetRandom(char[] chars, int length) 获取 char[] 内的随机数static intgetRandom(int max) 获取 0 - 最大随机数之间的随机数static intgetRandom(int min, int max) 获取两个数之间的随机数 ( 不含最大随机数, 需要 + 1)static String获取 String[] 内的随机数static String获取自定义数据自定义长度的随机数static StringgetRandomCapitalLetters(int length) 获取大写字母自定义长度的随机数static StringgetRandomLetters(int length) 获取大小写字母自定义长度的随机数static StringgetRandomLowerCaseLetters(int length) 获取小写字母自定义长度的随机数static StringgetRandomNumbers(int length) 获取数字自定义长度的随机数static StringgetRandomNumbersAndLetters(int length) 获取数字、大小写字母自定义长度的随机数static int[]ints(int streamSize, int randomNumberOrigin, int randomNumberBound) 获取随机 int[]static long[]longs(int streamSize, long randomNumberOrigin, long randomNumberBound) 获取随机 long[]static boolean获取伪随机 boolean 值static booleannextBoolean(Random random) 获取伪随机 boolean 值static byte[]nextBytes(byte[] data) 获取伪随机 byte[]static byte[]获取伪随机 byte[]static double获取伪随机 double 值static doublenextDouble(Random random) 获取伪随机 double 值static doublenextDoubleRange(double origin, double bound) 获取指定范围 double 值static float获取伪随机 float 值static float获取伪随机 float 值static double获取伪随机高斯分布值static doublenextGaussian(Random random) 获取伪随机高斯分布值static intnextInt()获取伪随机 int 值static intnextInt(int number) 获取伪随机 int 值 ( 该值介于 [0, n) 的区间 )static int获取伪随机 int 值static int获取伪随机 int 值 ( 该值介于 [0, n) 的区间 )static intnextIntRange(int origin, int bound) 获取指定范围 int 值static longnextLong()获取伪随机 long 值static long获取伪随机 long 值static longnextLongRange(long origin, long bound) 获取指定范围 long 值static int[]shuffle(int[] ints) 洗牌算法 ( 第一种 ) 随机置换指定的数组使用的默认源的随机性 ( 随机数据源小于三个, 则无效 )static int[]shuffle(int[] ints, int shuffleCount) 洗牌算法 ( 第一种 ) 随机置换指定的数组使用的默认源的随机性 ( 随机数据源小于三个, 则无效 )static boolean洗牌算法 ( 第一种 ) 随机置换指定的数组使用的默认源的随机性 ( 随机数据源小于三个, 则无效 )static boolean洗牌算法 ( 第一种 ) 随机置换指定的数组使用的默认源的随机性 ( 随机数据源小于三个, 则无效 )static boolean洗牌算法 ( 第二种 ) 随机置换指定的数组使用的默认源的随机性
-
方法详细资料
-
nextBoolean
获取伪随机 boolean 值- 参数:
random- Random- 返回:
- 随机 boolean 值
-
nextBytes
获取伪随机 byte[]- 参数:
random- Randomdata- 随机数据源- 返回:
- 随机 byte[]
-
nextDouble
获取伪随机 double 值- 参数:
random- Random- 返回:
- 随机 double 值
-
nextGaussian
获取伪随机高斯分布值- 参数:
random- Random- 返回:
- 伪随机高斯分布值
-
nextFloat
获取伪随机 float 值- 参数:
random- Random- 返回:
- 随机 float 值
-
nextInt
获取伪随机 int 值- 参数:
random- Random- 返回:
- 随机 int 值
-
nextInt
获取伪随机 int 值 ( 该值介于 [0, n) 的区间 )- 参数:
random- Randomnumber- 最大随机值- 返回:
- 随机介于 [0, n) 的区间值
-
nextLong
获取伪随机 long 值- 参数:
random- Random- 返回:
- 随机 long 值
-
nextBoolean
public static boolean nextBoolean()获取伪随机 boolean 值- 返回:
- 随机 boolean 值
-
nextBytes
public static byte[] nextBytes(byte[] data) 获取伪随机 byte[]- 参数:
data- 随机数据源- 返回:
- 随机 byte[]
-
nextDouble
public static double nextDouble()获取伪随机 double 值- 返回:
- 随机 double 值
-
nextGaussian
public static double nextGaussian()获取伪随机高斯分布值- 返回:
- 伪随机高斯分布值
-
nextFloat
public static float nextFloat()获取伪随机 float 值- 返回:
- 随机 float 值
-
nextInt
public static int nextInt()获取伪随机 int 值- 返回:
- 随机 int 值
-
nextInt
public static int nextInt(int number) 获取伪随机 int 值 ( 该值介于 [0, n) 的区间 )- 参数:
number- 最大随机值- 返回:
- 随机介于 [0, n) 的区间值
-
nextLong
public static long nextLong()获取伪随机 long 值- 返回:
- 随机 long 值
-
getRandomNumbers
获取数字自定义长度的随机数- 参数:
length- 长度- 返回:
- 随机字符串
-
getRandomLowerCaseLetters
获取小写字母自定义长度的随机数- 参数:
length- 长度- 返回:
- 随机字符串
-
getRandomCapitalLetters
获取大写字母自定义长度的随机数- 参数:
length- 长度- 返回:
- 随机字符串
-
getRandomLetters
获取大小写字母自定义长度的随机数- 参数:
length- 长度- 返回:
- 随机字符串
-
getRandomNumbersAndLetters
获取数字、大小写字母自定义长度的随机数- 参数:
length- 长度- 返回:
- 随机字符串
-
getRandom
获取自定义数据自定义长度的随机数- 参数:
source- 随机的数据源length- 长度- 返回:
- 随机字符串
-
getRandom
获取 char[] 内的随机数- 参数:
chars- 随机的数据源length- 需要最终长度- 返回:
- 随机字符串
-
getRandom
获取 String[] 内的随机数- 参数:
strings- 随机的数据源length- 需要最终长度- 返回:
- 随机字符串
-
getRandom
public static int getRandom(int max) 获取 0 - 最大随机数之间的随机数- 参数:
max- 最大随机数- 返回:
- 随机介于 [0, max) 的区间值
-
getRandom
public static int getRandom(int min, int max) 获取两个数之间的随机数 ( 不含最大随机数, 需要 + 1)- 参数:
min- 最小随机数max- 最大随机数- 返回:
- 随机介于 [min, max) 的区间值
-
shuffle
洗牌算法 ( 第一种 ) 随机置换指定的数组使用的默认源的随机性 ( 随机数据源小于三个, 则无效 )- 参数:
objects- 随机数据源- 返回:
truesuccess,falsefail
-
shuffle
洗牌算法 ( 第一种 ) 随机置换指定的数组使用的默认源的随机性 ( 随机数据源小于三个, 则无效 )- 参数:
objects- 随机数据源shuffleCount- 洗牌次数- 返回:
truesuccess,falsefail
-
shuffle
public static int[] shuffle(int[] ints) 洗牌算法 ( 第一种 ) 随机置换指定的数组使用的默认源的随机性 ( 随机数据源小于三个, 则无效 )- 参数:
ints- 随机数据源- 返回:
- 随机 int[]
-
shuffle
public static int[] shuffle(int[] ints, int shuffleCount) 洗牌算法 ( 第一种 ) 随机置换指定的数组使用的默认源的随机性 ( 随机数据源小于三个, 则无效 )- 参数:
ints- 随机数据源shuffleCount- 洗牌次数- 返回:
- 随机 int[]
-
shuffle2
洗牌算法 ( 第二种 ) 随机置换指定的数组使用的默认源的随机性- 参数:
objects- 随机数据源- 返回:
truesuccess,falsefail
-
nextIntRange
获取指定范围 int 值- 参数:
origin- 开始值bound- 范围值- 返回:
- 属于指定范围随机 int 值
- 抛出:
IllegalArgumentException- 参数错误
-
nextLongRange
获取指定范围 long 值- 参数:
origin- 开始值bound- 范围值- 返回:
- 属于指定范围随机 long 值
- 抛出:
IllegalArgumentException- 参数错误
-
nextDoubleRange
获取指定范围 double 值- 参数:
origin- 开始值bound- 范围值- 返回:
- 属于指定范围随机 double 值
- 抛出:
IllegalArgumentException- 参数错误
-
ints
public static int[] ints(int streamSize, int randomNumberOrigin, int randomNumberBound) 获取随机 int[]- 参数:
streamSize- 数组长度randomNumberOrigin- 开始值randomNumberBound- 结束值 ( 最大值范围 )- 返回:
- 指定范围随机 int[]
-
longs
public static long[] longs(int streamSize, long randomNumberOrigin, long randomNumberBound) 获取随机 long[]- 参数:
streamSize- 数组长度randomNumberOrigin- 开始值randomNumberBound- 结束值 ( 最大值范围 )- 返回:
- 指定范围随机 long[]
-
doubles
public static double[] doubles(int streamSize, double randomNumberOrigin, double randomNumberBound) 获取随机 double[]- 参数:
streamSize- 数组长度randomNumberOrigin- 开始值randomNumberBound- 结束值 ( 最大值范围 )- 返回:
- 指定范围随机 double[]
-