How can I generate a 6 digit integer using SecureRandom
class of Java?
I am trying the following code to generate random numbers :
SecureRandom secureRandom = new SecureRandom();
int secureNumber = secureRandom.nextInt();
It is generating random numbers with any length including negative number. I don't find any method in SecureRandom
class to provide a range of numbers. I want to generate a 6 digits positive random number
Maybe using this code?