Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
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.
import org.apache.commons.math3.random.RandomDataGenerator
import collection.JavaConverters._
val rng1 = new RandomDataGenerator()
val rng2 = new RandomDataGenerator()import org.apache.commons.math3.random.RandomDataGenerator
import collection.JavaConverters._
rng1: RandomDataGenerator = org.apache.commons.math3.random.RandomDataGenerator@254a5d85
rng2: RandomDataGenerator = org.apache.commons.math3.random.RandomDataGenerator@e18d0aeSystem.identityHashCode(rng1)res4: Int = 625630597System.identityHashCode(rng2)res5: Int = 236507310