The random() is an inbuilt method of StrictMath class in java which is used to get a double value with a positive sign that is greater than or equal to 0.0 and less than 1.0. random() method is accurately organized to acquiesce appropriate use by more than one thread. The values which are returned are adopted pseudorandomly with constant distribution from that range.
public static double random()
Parameters: The method does not accept any parameters.
Return Value: The method returns the pseudorandom double which is greater than or equal to 0.0 and less than 1.0.
Below programs illustrate the Java.lang.StrictMath.random() Method:
Generated random number = 0.7276560829796844 Generated random number = 0.6646167632286143
Generated random number = 0.5071995313935024 Generated random number = 0.6938224427158157
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.