java--random类

public class RandomDemo {
   public static void main( String args[] ){
      // create random object
      Random randomno = new Random();
      
      // get next next pseudorandom value 
      int value = randomno.nextInt();
      
      // check the value  
      System.out.println("Value is: " + value);
   }  
}

public int nextInt(int n) 返回大于等于0且小于n的随机整数

public long nextLong() 返回一个随机长整型值

public boolean nextBoolean() 返回一个随机布尔型值

public float nextFloat() 返回一个随机浮点型值

public double nextDouble() 返回一个随机双精度型值

public double nextGaussian() 返回一个概率密度为高斯分布的双精度值

你可能感兴趣的:(java)