public class DeterministicObject
extends java.lang.Object
Object
class. To remove one source of
nondeterminism from your program, do not instantiate the Object class, as in new
Object()
; instead do new DeterministicObject()
.
This class differs from Object in that it overrides hashCode()
. Any use of Object.hashCode()
is nondeterministic because the return value of Object.hashCode()
depends on when the garbage collector runs. That nondeterminism can affect the iteration order of
HashMaps and HashSets.
Constructor and Description |
---|
DeterministicObject()
Create a DeterministicObject.
|
Modifier and Type | Method and Description |
---|---|
int |
hashCode() |