Do I need to seed manually when using Random in java? -



Do I need to seed manually when using Random in java? -

in java:

i'm aware of random.setseed(long seed); does. know seed , how changes each use. need alter seed manually ensure sequence not repeat after time or automatically manipulates seeds using variable (such scheme clock)?

running same programme 1 time again not produce same results unless specify seed must manipulating seed in constructor changing seed periodically(i'm not talking changing of seed each use)?

clarification:

seed changes every usage @ point seed becomes number when random constructed.

do need phone call random.setseed(system.currenttimeinmillis()); 1 time in while ensure sequence not repeat after use?

it depends want. if want "random" repeatable, have fixed seeds. otherwise there's little reason prepare or alter seeds. reasons seeds include:

testing. specific pattern of randoms comes same each time. evaluation. different test cases same sequence of values , can compared.

if want alter seed, or have multiple random generators independent seeds, create new random objects.

java random random-seed

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -