How do you get random Double
values between 0.0 and 0.06 in Java?
nextDouble()
returns a random floating-point number uniformly distributed between 0 and 1. Simply scale the result as follows:
Random generator = new Random();
double number = generator.nextDouble() * .06;
See this documentation for more examples of Random.
This will give you a random double in the interval [0,0.06):
double r = Math.random()*0.06;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With