Obtaining a Random int Value

Consider the following statement:

int randomValue = randomNumbers.nextInt();

SecureRandom method nextInt generates a random int value. If it truly produces values at random, then every value in the range should have an equal chance (or probability) of being chosen each time nextInt is called.

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.