|
Java™ by example!
|
|
|
How do I generate a random double between x and y?
You can use the formula:
To get a random double number, instantiate a Random object and call the method nextDouble which returns a pseudo-random float between 0 and 1. Main.java:
outputs:
Further Information
Author of answer: Joris Van den Bogaert
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|