java.util.Random.nextLong() 方法
描述
nextLong() 方法用于从该随机数生成器的序列中返回下一个伪随机、均匀分布的 long 值。
声明
以下是 java.util.Random.nextLong() 方法的声明。
public long nextLong()
参数
NA
返回值
该方法调用从该随机数生成器的序列中返回下一个伪随机、均匀分布的长值。
异常
NA
示例
下面的例子展示了 java.util.Random.nextLong() 的用法。
package com.tutorialspoint;
import java.util.*;
public class RandomDemo {
public static void main( String args[] ) {
// create random object
Random randomno = new Random();
// get next long value
long value = randomno.nextLong();
// check the value
System.out.println("Long value is: " + value);
}
}
让我们编译并运行上面的程序,这将产生以下结果.
Long value is: 3285573610483682037

