Java Random(long seed) Constructor

Syntax

Random(long seed) constructor from Random has the following syntax.

public Random(long seed)

Example

In the following code shows how to use Random.Random(long seed) constructor.


//from  w  ww.  j a v  a2  s  .  c  om

import java.util.Random;

public class Main {
   public static void main( String args[] ){

      Random randomno = new Random(1234567890987655L);
      
      // get next next pseudorandom value 
      int value = randomno.nextInt();
      
      // check the value  
      System.out.println("Value is: " + value);
   }  
}

The code above generates the following result.