The next() method of Random class returns the next pseudorandom value from the random number generator’s sequence.
protected int next(int bits)
Parameters: The function accepts a single parameter bits which are the random bits.
Return Value: This method returns the next pseudorandom number.
Exception: The function does not throws any exception.
Program below demonstrates the above mentioned function:
Next value returns = 8
Next value returns = 54
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.