The moose likes Java in General and the fly likes Random seed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Storm Applied this week in the Other Open Source APIs forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Random seed" Watch "Random seed" New topic

Random seed

Matti Poro
Ranch Hand

Joined: Dec 03, 2005
Posts: 41
Do Random-objects with the same seed give the same values every time, on every computer and on every Java Virtual Machine implementation (>=JRE 1.5)?
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
According to the API, yes. "Java implementations must use all the algorithms shown here for the class Random, for the sake of absolute portability of Java code. However, subclasses of class Random are permitted to use other algorithms, so long as they adhere to the general contracts for all the methods." So as long as you use an actual Random and not a subclass you should be fine.

"I'm not back." - Bill Harding, Twister
It is sorta covered in the JavaRanch Style Guide.
subject: Random seed