java tutorial - Java Math.random() Method - java programming - learn java - java basics - java for beginners
Learn Java - Java tutorial - Java numbers random - Java examples - Java programs
Description
The method Math.random () - in Java is used to generate a random number in the range from 0.0 to 1.0. Different ranges can be achieved using arithmetic.
Syntax
Options
Detailed information about the parameters:
- The default method does not take a parameter.
Return value
- In Java Math.random () Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0 (0.0 <= Math.random () <1.0).
Example 1
Output
Note:The result will change every time you call the Math.random () method.
Example2: a random number between 0 and 10
Output
Learn java - java tutorial - java random advance - java examples - java programs