title: singleton public static final
body: <p>I've been wondering about singletons in Java. By convention, a singleton is set up something like this:</p>
  
  <pre><code>private static MyClass instance = null;
  public static MyClass getInstance(){
      if (instance == null){
          instance = new MyClass();
      }
      return instance;
  }
  private MyClass(){}
  </code></pre>
  
  <p>Recently I've switched to using the following:</p>
  
  <pre><code>public static final MyClass instance = new MyClass();
  private MyClass(){}
  </code></pre>
  
  <p>This is a lot shorter, faster as there's no null-check, and typing <code>MyClass.instance</code> feels nicer to me than typing <code>MyClass.getInstance()</code>. Is there any reason why the second is not the mainstream way to do this?</p>