posted 1 year ago
Hi everybody
Could someone please help me understand the mathematical function (Math.random()* 10).
I understand it is a mathematical function that generates random numbers, but how does *10 limit the random numbers from 0 to 9. is it just something i must remember or is there a reason behind it.
Could someone please help me understand the mathematical function (Math.random()* 10).
I understand it is a mathematical function that generates random numbers, but how does *10 limit the random numbers from 0 to 9. is it just something i must remember or is there a reason behind it.
posted 1 year ago
 1
Don't do arithmetic on Math#random. Create an instance of the Random class because it has many methods which are easier to use. Read their documentation carefully before you use them. You probably want myRandom.nextInt(10).
Note that Math#random uses a Random instance behind the scenes anyway.
Note that Math#random uses a Random instance behind the scenes anyway.
You have to be odd to be #1  Seuss. An odd little ad:
The WEB SERVICES and JAXRS Course
https://coderanch.com/t/690789/WEBSERVICESJAXRS
