Java Random NextLong()方法及示例
Random类 的 nextGaussian() 方法从这个随机数发生器的序列中返回下一个伪随机的、均匀分布的长值。
语法
public long nextLong()
参数: 该函数不接受任何参数。
返回值 :该方法返回下一个伪随机、均匀分布的长值。
异常: 该函数不抛出任何异常。
下面的程序演示了上述的函数。
// program to demonstrate the// function java.util.Random.nextLong() import java.util.*;public class GFG { public static void main(String[] args) { // create random object Random r = new Random(); // get next long value and print the value System.out.println("Long value is = " + r.nextLong()); }}
输出:
Long value is = -9027907281942573746
// program to demonstrate the// function java.util.Random.nextLong() import java.util.*;public class GFG { public static void main(String[] args) { // create random object Random r = new Random(); // get next long value and print the value System.out.println("Long value is = " + r.nextLong()); }}输出:
Long value is = -2817123387200223163
