previous | start | next

## Random Number Generator Singleton

`public class SingleRandom`
`{`
`private SingleRandom() { generator = new Random(); }`
`public void setSeed(int seed) { generator.setSeed(seed); }`
`public int nextInt() { return generator.nextInt(); }`
`public static SingleRandom getInstance() { return instance; }`
`private Random generator;`
`private static SingleRandom instance = new SingleRandom();`
`}`

previous | start | next