Random类提供了产生多种形式随机数的功能。虽然Math类的random()能产生随机数,但它只能产生0.0-1.0之间的随机数。若需要大量的不同形式的随机数,可用Random类。


Random类常用的方法:

    boolean nextBoolean()
    返回true或false中的一个

     double nextDouble()
     返回0.0~1.0之间的double小数

      float nextFloat()
      返回0.0~1.0之间的float小数

      int nextInt()
      返回int型整数

     int nextInt(int n)
     返回0到n-1之间的整数

     long nextLong()
     返回long型整数