Get a random double value greater than or equal to 0.0 and less than 1.0 in Java
Description
The following code shows how to get a random double value greater than or equal to 0.0 and less than 1.0.
Example
/*from www . jav a 2 s .co m*/
public class Main {
public static void main(String[] args) {
int a = 10;
int b = -50;
System.out.println("random() = " + Math.random());
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »