title: Design decision - What is the use/advantage of separate RandomNumberGeneratorHolder class in Math.java?
body: <p>So I was going through the <code>Math.java</code> source code and I found that there is a holder class created to hold the <a href="http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/lang/Math.java#l745" rel="nofollow noreferrer"><code>randomNumberGenerator</code></a> static variable. Here is the relevant piece of code.</p>
  
  <pre><code>public final class Math {
   // other methods.
   public static double random() {
     return RandomNumberGeneratorHolder.randomNumberGenerator.nextDouble();
   }
  
   private static final class RandomNumberGeneratorHolder {
     static final Random randomNumberGenerator = new Random();
   }
  }
  </code></pre>
  
  <p>IMO, We could have simply declared the <code>randomNumberGenerator</code> as <code>private static final</code> inside the <code>Math</code> class itself. </p>
  
  <p>My question is, Is there any advantage of creating a separate holder class for this? Or it is just a personal preference.</p>