Java Random Long randomLong(long min, long max)

Here you can find the source of randomLong(long min, long max)

Description

Generates pseudo-random long from specific range.

License

Open Source License

Parameter

Parameter Description
min lower (inclusive) boundary
max higher (exclusive) boundary

Return

pseudo-random value

Declaration


public static long randomLong(long min, long max) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  w w  w.  j  a  va  2 s.  com*/
     * Generates pseudo-random long from specific range. Generated number is
     * great or equals to min parameter value and less then max parameter value.
     * Uses {@link Math#random()}.
     *
     * @param min    lower (inclusive) boundary
     * @param max    higher (exclusive) boundary
     *
     * @return pseudo-random value
     */

    public static long randomLong(long min, long max) {
        return min + (long) (Math.random() * (max - min));
    }
}

Related

  1. random(long min, long max)
  2. random(long range)
  3. randomHexOfLong(long max)
  4. randomLong()
  5. randomLong()
  6. randomLong(long x, long y)
  7. randomLongWithMinMax(long min, long max)
  8. randomSleep(long ms)
  9. randomStr(long strLen)