public class Randoms extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Randoms.ArrayRandom<E> |
static class |
Randoms.ListRandom<E> |
Modifier and Type | Method and Description |
---|---|
static Random |
getRandom() |
static Random |
getRandom(boolean threadLocal) |
static <E> Randoms.ArrayRandom<E> |
randomArray(E[] array)
根据一个数组随机产生对象, 每个对象只会被取出一次, 当数组耗尽, 则一直返回 null
|
static String |
randomAscii(int length)
返回一个定长的随机字母+数字
|
static boolean |
randomBoolean()
返回一个随机的布尔值
|
static boolean |
randomBoolean(double ratio)
返回一个随机的布尔值 ratio%
|
static boolean |
randomBoolean(int ratio)
返回一个随机的布尔值
|
static char |
randomChineseChar()
随机一个字符
|
static String |
randomChineseString()
随机一个字符串
|
static String |
randomChineseString(int count)
随机一个字符串
|
static double |
randomDouble()
随机一个数字
|
static double |
randomDouble(double max)
随机一个数字
|
static double |
randomDouble(double min,
double max)
随机一个数字
|
static int |
randomInt()
随机一个数字
|
static int |
randomInt(int max)
随机一个数字
|
static int |
randomInt(int min,
int max)
随机一个数字
|
static String |
randomLetter(int length)
返回一个定长的随机纯字母字符串
|
static <E> Randoms.ListRandom<E> |
randomList(List<E> list)
根据一个集合随机产生对象, 每个对象只会被取出一次, 当数组耗尽, 则一直返回 null
|
static long |
randomLong()
随机一个数字
|
static long |
randomLong(long max)
随机一个数字
|
static long |
randomLong(long min,
long max)
随机一个数字
|
static String |
randomNumber(int length)
返回固定长度的数字
|
public static final Random RANDOM
public static Random getRandom()
public static Random getRandom(boolean threadLocal)
public static char randomChineseChar()
public static String randomChineseString()
public static String randomChineseString(int count)
count
- 长度public static String randomAscii(int length)
length
- 长度public static String randomLetter(int length)
length
- 长度public static int randomInt()
public static int randomInt(int max)
max
- 最大值 不包含public static int randomInt(int min, int max)
min
- 最小值 包含max
- 最大值 不包含public static double randomDouble()
public static double randomDouble(double max)
max
- 最大值 不包含public static double randomDouble(double min, double max)
min
- 最小值 包含max
- 最大值 不包含public static long randomLong()
public static long randomLong(long max)
max
- 最大值 不包含public static long randomLong(long min, long max)
min
- 最小值 包含max
- 最大值 不包含public static boolean randomBoolean()
public static boolean randomBoolean(int ratio)
ratio
- 几率 1/ratiopublic static boolean randomBoolean(double ratio)
ratio
- ratio 0 ~ 1public static String randomNumber(int length)
length
- 长度public static <E> Randoms.ArrayRandom<E> randomArray(E[] array)
E
- ignorearray
- 数组public static <E> Randoms.ListRandom<E> randomList(List<E> list)
E
- ignorelist
- 集合Copyright © 2024. All rights reserved.