Java.util.Random null argument request

I am trying to encode a game by following the instructions contained in the OU TMA document that states:

In the constructor, write code to designate a new instance of Random to run, which you must create using the constructor of the arguments of the null class Random

Will this code work?

Random ran = new Random(0) ;

I am a relative newbie in Java and I do not understand what the following commands mean:

+5
source share
1 answer

No, that will not work. A constructor with a null argument is a constructor that accepts no arguments :

Random ran = new Random();

- way.

The difference between the two constructors is well described in the API docs:

Random()
. , , , .

    Random(long seed)
, : public Random(long seed) { setSeed(seed); }

Random, , , , (, ), .

+6

All Articles