Here you can find the source of random(long min, long max)
Parameter | Description |
---|---|
min | the minimum value. |
max | the maximum value. |
Parameter | Description |
---|---|
ArgumentMalformedException | if the value <tt>min</tt>is greater than the value <tt>max</tt> |
public static long random(long min, long max)
//package com.java2s; //License from project: Apache License public class Main { /**/*w w w . j a v a 2 s . c om*/ * Returns a random long number between the value <tt>min</tt> * and the value <tt>max</tt>. * @param min the minimum value. * @param max the maximum value. * @return a random long number between the value <tt>min</tt> * and the value <tt>max</tt>. * @throws ArgumentMalformedException if the value <tt>min</tt> * is greater than the value <tt>max</tt> */ public static long random(long min, long max) { if (min > max) { throw new ArithmeticException( "min" + String.valueOf(min) + "Value min " + min + " must be lesser than value max " + max); } return (long) (Math.random() * (max - min) + min); } }