Tips and Traps¶
- You cannot get the address of an object in Java (without hacking).
System.identityHashCode(obj)
is the next best thing you can have. This trick (combined with the timestamp) is used to generate default seed for random number generators in Java.
In [4]:
import org.apache.commons.math3.random.RandomDataGenerator
import collection.JavaConverters._
val rng1 = new RandomDataGenerator()
val rng2 = new RandomDataGenerator()
Out[4]:
In [5]:
System.identityHashCode(rng1)
Out[5]:
In [6]:
System.identityHashCode(rng2)
Out[6]:
References¶
In [ ]: