程序包 cool.scx.util

类 RandomUtils

java.lang.Object
cool.scx.util.RandomUtils

public final class RandomUtils extends Object
用于生成简单的随机数
版本:
0.0.1
作者:
scx567888
  • 构造器详细资料

    • RandomUtils

      public RandomUtils()
  • 方法详细资料

    • randomString

      public static String randomString(int size, boolean withLetter)
      获取随机的 Code 注意!!! 此方法和 getUUID 不同 若需要获取 uuid 请使用 getUUID
      参数:
      size - code 的长度
      withLetter - code 中是否包含字母
      返回:
      a String object
    • randomString

      public static String randomString(int size)
      获取随机的 Code (包含字母和数字)
      参数:
      size - code 的长度
      返回:
      a
    • randomNumber

      public static int randomNumber(int min, int max)
      取一个指定区间的随机数 (包含两端)
      参数:
      min - 最小值
      max - 最大值
      返回:
      随机数
    • randomUUID

      public static String randomUUID()
      获取UUID
      返回:
      a String object.
    • randomGet

      @SafeVarargs public static <T> T randomGet(T... array)
      随机从数组中取出一个元素
      类型参数:
      T - T
      参数:
      array - 数组
      返回:
      随机的元素
    • randomGet

      public static <T> T randomGet(List<T> list)
      随机从列表中取出一个元素
      类型参数:
      T - T
      参数:
      list - 列表
      返回:
      随机的元素
    • randomGet

      public static <T> T[] randomGet(T[] array, int size)
      随机从数组中取出 多个元素 (不会重复)
      类型参数:
      T - t
      参数:
      array - 数组
      size - 长度
      返回:
      a
    • randomGet

      public static <T> List<T> randomGet(List<T> list, int size)
      随机从数组中取出 多个元素 (不会重复)
      类型参数:
      T - a
      参数:
      list - 数组
      size - 长度
      返回:
      a
    • nextInt

      public static int nextInt(int bound)
    • nextInt

      public static int nextInt(int origin, int bound)