程序包 cool.scx.util
类 RandomUtils
java.lang.Object
cool.scx.util.RandomUtils
用于生成简单的随机数
- 版本:
- 0.0.1
- 作者:
- scx567888
-
嵌套类概要
嵌套类 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static booleanstatic voidrandomBytes(byte[] bytes) 填充用户提供的 byte 数组, 范围 -128 (包含) 到 127 (包含)static byte[]randomBytes(int size) 生成一个新的随机 byte 数组static doublestatic doublerandomDouble(double bound) static doublerandomDouble(double origin, double bound) 返回随机数static floatstatic floatrandomFloat(float bound) static floatrandomFloat(float origin, float bound) 返回随机数static <T> T随机从列表中取出一个元素static <T> List<T> 随机从数组中取出 多个元素 (不会重复)static <T> TrandomGet(T... array) 随机从数组中取出一个元素static <T> T[]randomGet(T[] array, int size) 随机从数组中取出 多个元素 (不会重复)static intstatic intrandomInt(int bound) static intrandomInt(int origin, int bound) 返回随机数static longstatic longrandomLong(long bound) static longrandomLong(long origin, long bound) 返回随机数static StringrandomString(int size) 获取随机的 字符串 (包含字母和数字)static StringrandomString(int size, RandomUtils.PoolType poolType) 获取随机的 字符串 注意!!!static StringrandomString(int size, String pool) 获取随机的 字符串static StringrandomString(int size, String[] pool) 获取随机的 字符串static String获取 UUID
-
构造器详细资料
-
RandomUtils
public RandomUtils()
-
-
方法详细资料
-
randomString
获取随机的 字符串 注意!!! 此方法和 getUUID 不同 若需要获取 uuid 请使用 getUUID- 参数:
size- 字符串 的长度poolType- 候选池类型- 返回:
- 随机的 字符串
-
randomString
获取随机的 字符串 (包含字母和数字)- 参数:
size- 长度- 返回:
- 随机的 字符串
-
randomString
获取随机的 字符串- 参数:
size- 长度pool- 候选池 (会被切割成单个字符)- 返回:
- 随机的 字符串
-
randomString
获取随机的 字符串- 参数:
size- 长度pool- 候选池- 返回:
- 随机的 字符串
-
randomUUID
获取 UUID- 返回:
- UUID
-
randomGet
随机从数组中取出一个元素- 类型参数:
T- T- 参数:
array- 数组- 返回:
- 随机的元素
-
randomGet
随机从列表中取出一个元素- 类型参数:
T- T- 参数:
list- 列表- 返回:
- 随机的元素
-
randomGet
public static <T> T[] randomGet(T[] array, int size) 随机从数组中取出 多个元素 (不会重复)- 类型参数:
T- t- 参数:
array- 数组size- 长度- 返回:
- a
-
randomGet
随机从数组中取出 多个元素 (不会重复)- 类型参数:
T- a- 参数:
list- 数组size- 长度- 返回:
- a
-
randomBoolean
public static boolean randomBoolean() -
randomBytes
public static byte[] randomBytes(int size) 生成一个新的随机 byte 数组- 参数:
size- 长度- 返回:
- byte 数组
-
randomBytes
public static void randomBytes(byte[] bytes) 填充用户提供的 byte 数组, 范围 -128 (包含) 到 127 (包含)- 参数:
bytes- bytes
-
randomFloat
public static float randomFloat() -
randomFloat
public static float randomFloat(float bound) -
randomFloat
public static float randomFloat(float origin, float bound) 返回随机数- 参数:
origin- 起始 (包含)bound- 结束 (不包含)- 返回:
- int
-
randomDouble
public static double randomDouble() -
randomDouble
public static double randomDouble(double bound) -
randomDouble
public static double randomDouble(double origin, double bound) 返回随机数- 参数:
origin- 起始 (包含)bound- 结束 (不包含)- 返回:
- int
-
randomInt
public static int randomInt() -
randomInt
public static int randomInt(int bound) -
randomInt
public static int randomInt(int origin, int bound) 返回随机数- 参数:
origin- 起始 (包含)bound- 结束 (不包含)- 返回:
- int
-
randomLong
public static long randomLong() -
randomLong
public static long randomLong(long bound) -
randomLong
public static long randomLong(long origin, long bound) 返回随机数- 参数:
origin- 起始 (包含)bound- 结束 (不包含)- 返回:
- int
-