Java Random Int randInt(int min, int max)

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

Description

Returns a random integer between min and max.

License

Open Source License

Parameter

Parameter Description
min a parameter
max a parameter

Declaration

public static int randInt(int min, int max) 

Method Source Code

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

import java.util.Random;

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

    /**//from w w w  .  j a  v a2 s. c o  m
     *Returns a random integer between min and max.
     * @param min
     * @param max
     * @return
     */
    public static int randInt(int min, int max) {
        int randomNum = r.nextInt((max - min) + 1) + min;
        return randomNum;
    }
}

Related

  1. randint(int max)
  2. randInt(int min, int max)
  3. randInt(int min, int max)
  4. randInt(int min, int max)
  5. randInt(int min, int max)
  6. randInt(int min, int max)
  7. randInt(int min, int max)
  8. randInt(int min, int max)
  9. randInt(int min, int max)