Following is the syntax of random method. The Java Mathrandom method is used to generate a pseudorandom number which is a number created with a formula that simulates randomness. The Math class contains the static Mathrandom method to generate random.
Mathrandom random being a static method is called using the Math class name.
This Mathrandom gives a random double from 00 inclusive to 10 exclusive. Formula int rand intMathrandom100. We can also use the following formula if we want to a generate random number between a specified range. Public class MathDemo public static void mainString args get two random double numbers double x Mathrandom.