Export (0) Print
Expand All

Random.setSeed Method

Visual Studio 2005

Sets the seed used to initialize the random number generator.

Package: java.util

Assembly: vjslib (in vjslib.dll)


public synchronized void setSeed(
    long seed);

Parameters

seed

The seed used to initialize the random number generator.

The following example shows how to initialize the random number generator using the current time.

// random_setseed.jsl

import java.util.*;

public class Program
{
    public static void main(String[] args)
    {
        // Get the current time.
        Date date = new Date();
        long time = date.getTime();

        Random r = new Random();

        // Initialize the random number generator using the
        // time from above.
        r.setSeed(time);
    }
}

Community Additions

ADD
Show:
© 2014 Microsoft