Here you can find the source of randInt(int n)
Parameter | Description |
---|---|
n | - maximum value (exclusive) |
public static int randInt(int n)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from ww w . j av a2 s. c o m*/ * Generates a random integer in the range [0,n). * * @param n - maximum value (exclusive) * @return - random integer */ public static int randInt(int n) { return (int) randInt(0, n); } /** * Generates a random integer in the given range. * * @param minrange - minumum value (inclusive) * @param maxrange - maximum value (exclusive) * @return - random integer */ public static int randInt(int minrange, int maxrange) { return (int) randRealUniform(minrange, maxrange); } /** * Generates a random real number in the given range. * * @param minrange - minimum value * @param maxrange - maximum value * @return - random number */ public static double randRealUniform(double minrange, double maxrange) { return minrange + (Math.random() * (maxrange - minrange)); } }