类 Randoms

java.lang.Object
com.weicoder.common.statics.Randoms
直接已知子类:
S.R

public class Randoms extends Object
随机数使用类
作者:
wdcode
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    static Random
    返回当前线程的ThreadLocalRandom
    static byte[]
    nextBytes(int len, int m, int n)
    随机获得一个字节数组 确保输入的m和n在byte之内 不做额外验证
    static byte[]
    nextBytes(Random r, int len, int m, int n)
    随机获得一个字节数组 确保输入的m和n在byte之内 不做额外验证
    static byte[]
    nextBytes(Random r, int len, int s, int e, boolean is)
    随机获得一个字节数组 确保输入的m和n在byte之内 不做额外验证
    static List<byte[]>
    nextBytes(Random r, int len, int s, int e, int n, boolean is)
    随机获得一个字节数组列表 验证s与e在Byte.min~Byte.max之间
    static double
    同方法Random.nextDouble()
    static float
    同方法Random.nextFloat()
    static int
    同方法Random.nextInt()
    static int
    nextInt(int n)
    同方法Random.nextInt(n)
    static int
    nextInt(int m, int n)
    在m-n的范围中随机获得
    static long
    同方法Random.nextLong()
    static Random
    声明个新的Random
    static String
    random(int len)
    获取指定位数的随机数
    static Random
    声明个新的SecureRandom

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • Randoms

      public Randoms()
  • 方法详细资料

    • current

      public static Random current()
      返回当前线程的ThreadLocalRandom
      返回:
      ThreadLocalRandom 独立线程的随机数
    • random

      public static Random random()
      声明个新的Random
      返回:
      Random
    • secure

      public static Random secure()
      声明个新的SecureRandom
      返回:
      SecureRandom
    • nextBytes

      public static byte[] nextBytes(int len, int m, int n)
      随机获得一个字节数组 确保输入的m和n在byte之内 不做额外验证
      参数:
      len - 生成长度
      m - 开始数
      n - 结束数
      返回:
      字节数组
    • nextBytes

      public static byte[] nextBytes(Random r, int len, int m, int n)
      随机获得一个字节数组 确保输入的m和n在byte之内 不做额外验证
      参数:
      r - 随机数生成类
      len - 生成长度
      m - 开始数
      n - 结束数
      返回:
      字节数组
    • nextBytes

      public static byte[] nextBytes(Random r, int len, int s, int e, boolean is)
      随机获得一个字节数组 确保输入的m和n在byte之内 不做额外验证
      参数:
      r - 随机数生成类
      len - 生成长度
      is - 是否可重复 true 可重复 false 不可重复
      m - 开始数
      n - 结束数
      返回:
      字节数组
    • nextBytes

      public static List<byte[]> nextBytes(Random r, int len, int s, int e, int n, boolean is)
      随机获得一个字节数组列表 验证s与e在Byte.min~Byte.max之间
      参数:
      r - 随机数生成类
      len - 生成长度
      s - 开始数
      e - 结束数
      n - 生成列表长度
      is - 是否可重复 true 可重复 false 不可重复
      返回:
      字节数组
    • nextInt

      public static int nextInt()
      同方法Random.nextInt()
      返回:
      int 返回的随机数
    • nextInt

      public static int nextInt(int n)
      同方法Random.nextInt(n)
      参数:
      n - 在0-n的范围中
      返回:
      int 返回的随机数
    • nextInt

      public static int nextInt(int m, int n)
      在m-n的范围中随机获得
      参数:
      m - 起始数
      n - 结束数
      返回:
      int 返回的随机数
    • nextDouble

      public static double nextDouble()
      同方法Random.nextDouble()
      返回:
      double 返回的随机数
    • nextFloat

      public static float nextFloat()
      同方法Random.nextFloat()
      返回:
      float 返回的随机数
    • nextLong

      public static long nextLong()
      同方法Random.nextLong()
      返回:
      long 返回的随机数
    • random

      public static String random(int len)
      获取指定位数的随机数
      参数:
      len - 随机长度
      返回:
      字符串格式的随机数