Java ThreadLocalRandom randomInteger(int min, int max)

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

Description

Generates and returns a pseudorandom integer value between min and max (inclusive).

License

Open Source License

Parameter

Parameter Description
min The minimum range value, inclusive.
max The maximum range value, inclusive.

Return

A pseudorandom integer value between min and max arguments(inclusive).

Declaration

public static int randomInteger(int min, int max) 

Method Source Code

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

import java.util.concurrent.ThreadLocalRandom;

public class Main {
    /**/*from w  w w  . j a  v  a 2 s. c  o  m*/
     * Generates and returns a pseudorandom integer value between {@code min} 
     * and {@code max} (inclusive).
     * 
     * @param min The minimum range value, inclusive.
     * @param max The maximum range value, inclusive.
     * @return A pseudorandom integer value between {@code min} and {@code max}
     *         arguments(inclusive).
     */
    public static int randomInteger(int min, int max) {
        return ThreadLocalRandom.current().nextInt(min, max + 1);
    }
}

Related

  1. randomFixedChars(int size, List pool)
  2. randomIndexs(int count, int bound)
  3. randomInRange(int min, int max)
  4. randomInt()
  5. randomInt(int bound)
  6. randomIntegerList(int min, int max, int minLength, int maxLength)
  7. randomLongs(final long count, final long min, final long max)
  8. randomLongsNonDuplicates(final long count, final long min, final long max)
  9. randomNum(int min, int max)