Java Random Int randInt(int min, int max)

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

Description

Get a random integer within the provided range.

License

Open Source License

Parameter

Parameter Description
min The minimum value.
max The maximum value.

Return

A random integer within the provided range.

Declaration

public static int randInt(int min, int max) 

Method Source Code

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

public class Main {
    /**//from  w ww  .  j  a v  a 2  s  . c  o  m
     * Get a random integer within the provided range.
     *
     * @param min The minimum value.
     * @param max The maximum value.
     * @return A random integer within the provided range.
     */
    public static int randInt(int min, int max) {
        return min + (int) (Math.random() * ((max - min) + 1));
    }
}

Related

  1. randInt(int min, 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)