Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to generate random number in Java?

    • 0
    • 2
    • 0
    • 3
    • 0
    • 0
    • 0
    • 0
    • 794
    Comment on it

    Sometimes we need to generate random numbers to identify an entity uniquely. We can generate random number very easily by the below code:

    /**
     * 
     * @return a random confirmation code.
     */
    public int generateIntRandomNumber()
    {
         Random generator = new Random();
         int i = generator.nextInt(999999999);
         return i;
    }
    

    Hope this will help you :)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: