Java Random Int getRandomInt(int max)

Here you can find the source of getRandomInt(int max)

Description

Get a random int within [0, max) range.

License

Apache License

Parameter

Parameter Description
max a parameter

Declaration

public static final int getRandomInt(int max) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Random;

public class Main {
    private static final Random RANDOM = new Random();

    /**/* w w  w .j  a  va 2s  .c  o  m*/
     * Get a random int within [0, max) range.
     * @param max
     * @return
     */
    public static final int getRandomInt(int max) {
        return RANDOM.nextInt(max);
    }
}

Related

  1. getRandomInt(int intStart, int intEnd)
  2. getRandomInt(int lower, int upper)
  3. getRandomInt(int lower, int upper)
  4. getRandomInt(int max)
  5. getRandomInt(int max)
  6. getRandomInt(int min, int max)
  7. getRandomInt(int min, int max)
  8. getRandomInt(int min, int max, Random random)
  9. getRandomInt(int minimum, int maximum)