How do I get the seed from a Random in Java?
问题 I am creating a deep clone for some object. The object contains a Random . Is it good practice to retrieve the seed from the Random ? If so, how? There isn't a Random.getSeed() . 回答1: A Random is intended to be random. Usually you want two Random to produce different numbers rather than to produce the same numbers. You can copy a Random using serialisation/de-serialisation and get the "seed" field using reflection. (But I doubt you should be doing either) Unless the sequence is critical to