Get Random long type number in Java

Description

The following code shows how to get Random long type number.

Example


//from  w w  w . j  a va  2  s .  com
import java.util.Random;

public class Main {
  public static void main(String[] argv) throws Exception {

    Random rand = new Random();

    boolean b = rand.nextBoolean();
    long l = rand.nextLong();
    
    System.out.println(l);
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    Development »




Java Algorithms
Java Clipboard
Java Compiler
Java Desktop
Java Virtual Machine
Java Math
OS
Random
Java Robot
Java RuntimeMXBean
Java Timer
Java UUID
Java Internationalization