Java Random getRandom()

Here you can find the source of getRandom()

Description

get Random

License

Open Source License

Return

Shared random generator used in this package

Declaration

static Random getRandom() 

Method Source Code

//package com.java2s;
import java.util.*;

public class Main {
    private static Random random;

    /**/*  w w w. j a va2  s .  co m*/
     * @return Shared random generator used in this package
     */
    static Random getRandom() {
        if (random != null)
            return random;
        else
            return getRandom(System.currentTimeMillis());
    }

    /**
     * Set up shared random generator to use the given seed.
     *
     * @return Shared random generator object
     */
    static Random getRandom(long seed) {
        random = new Random(seed);
        System.err.printf("Random generator initialized with seed %d%n",
                seed);

        return random;
    }
}

Related

  1. getItemID(Random r)
  2. getOreMultiplier(int fortune, Random r)
  3. getPoisson(double lambda, Random rng)
  4. getRandom()
  5. getRandom()
  6. getRandom(Collection collection)
  7. getRandom(int i)
  8. getRandom(int min, int max)
  9. getRandomDigits(Random r, int l, int radix)