Java Random Int rand(int min, int max)

Here you can find the source of rand(int min, int max)

Description

Generates a random number

License

Open Source License

Parameter

Parameter Description
min The lowest number allowed
max The highest number allowed

Return

Returns a random int between the specified boundaries

Declaration

public static int rand(int min, int max) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*w ww.j a v  a2 s  . c om*/
     * Generates a random number
     *
     * @param min The lowest number allowed
     * @param max The highest number allowed
     * @return Returns a random int between the specified boundaries
     */
    public static int rand(int min, int max) {
        return min + (int) (Math.random() * ((max - min) + 1));
    }
}

Related

  1. getRandomIntegerInRange(Random random, int i, int j)
  2. getRandomInterests()
  3. getRandomIntFromRange(int min, int max)
  4. getRandomInts(int number)
  5. getRandomIntStr(int len)
  6. rand(int size)
  7. randBetween(int min, int max)
  8. randInRangeInc(int min, int max)
  9. randInt()