Java Random Byte rand(int max)

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

Description

Get a random integer less than a given value.

License

Open Source License

Parameter

Parameter Description
max the maximum (exclusive) value of the number

Return

a pseudo randomly generated number above 0

Declaration

public static int rand(int max) 

Method Source Code


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

import java.util.Random;

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

    /** Get a random integer less than a given value.
     * // w  w w.j  av a2 s. com
     * @param max the maximum (exclusive) value of the number
     * @return a pseudo randomly generated number above 0
     */
    public static int rand(int max) {
        return randomSet.nextInt(max);
    }
}

Related

  1. rand(int lbound, int ubound)
  2. rand(int lo, int hi)
  3. rand(int lo, int hi)
  4. rand(int lo, int hi)
  5. Rand(int lo, int hi)
  6. randByte()
  7. randomByte()