Get Random double type number in Java
Description
The following code shows how to get Random double type number.
Example
//from w w w .j a v a2s .c o m
import java.util.Random;
public class Main {
public static void main(String[] argv) throws Exception {
Random rand = new Random();
double d = rand.nextDouble(); // 0.0 <= d < 1.0
System.out.println(d);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »