Java Random Long randPosLong()

Here you can find the source of randPosLong()

Description

simply uses Math.random, only 0 and positive longs returned

License

Open Source License

Declaration

public static long randPosLong() 

Method Source Code

//package com.java2s;

public class Main {
    /**//ww  w .ja  v a  2  s  .c o m
     * simply uses Math.random, only 0 and positive longs returned
     *
     */
    public static long randPosLong() {
        return randPosLong(Long.MAX_VALUE);
    }

    /**
     * simply uses Math.random, only 0 and positive returned. Possibly not all
     * long values can be returned, check details of java random.
     *
     */
    public static long randPosLong(long max) {
        return (long) (Math.random() * max);
    }
}

Related

  1. randomLong(long x, long y)
  2. randomLongWithMinMax(long min, long max)
  3. randomSleep(long ms)
  4. randomStr(long strLen)
  5. randomStr(long strLen)
  6. secureRandomLong()