title: What is the issue with this java singleton class implementation?
body: <p>I have come across another article in stackexchange on various ways to implement java singleton. One of the ways shown is the following example. It has been voted very low. Wanted to understand why.
  <a href="https://stackoverflow.com/questions/70689/what-is-an-efficient-way-to-implement-a-singleton-pattern-in-java">What is an efficient way to implement a singleton pattern in Java?</a></p>
  
  <pre><code>public class Singleton {
  
      private static Singleton instance = null;
  
      static {
            instance = new Singleton();
            // do some of your instantiation stuff here
      }
  
      private Singleton() {
            if(instance!=null) {
                    throw new ErrorYouWant("Singleton double-instantiation, should never happen!");
            }
      }
  
      public static getSingleton() {
            return instance;
      }
  
  }
  </code></pre>