Java Random Int randInt(int min, int max)

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

Description

rand Int

License

Open Source License

Parameter

Parameter Description
min Lower bound of random interval
max Upper bound of random interval

Return

Random integer number from min to max interval

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 Random mRandom = new Random();

    /**/*from  w  w w.  j  av a  2  s  .co m*/
     *
     * @param min Lower bound of random interval
     * @param max Upper bound of random interval
     * @return Random integer number from min to max interval
     */
    public static int randInt(int min, int max) {
        return mRandom.nextInt((max - min) + 1) + min;
    }
}

Related

  1. randInt(int low, int high)
  2. randInt(int max)
  3. randint(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)