call nextDouble() to get next random double value
/*
* Output:
*
* 0.8102628210601169
*
*/
import java.util.Random;
public class MainClass {
public static void main(String args[]) {
Random rand = new Random();
System.out.println(rand.nextDouble());
}
}
Home
Java Book
Essential Classes
Java Book
Essential Classes
Random:
- Random
- Call nextInt() to get random integers
- call nextDouble() to get next random double value
- Call nextGaussian() to get next double value centered at 0.0 with a standard deviation of 1.0.