|
Java™ by example!
|
|
|
How do I generate a random float between x and y?
You can use the formula:
To get a random float number, instantiate a Random object and call the method nextFloat 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!
|
|
|
|
|