title: How to write a Singleton in proper manner?
body: <p>Today in my interview one interviewer asked me to write a Singleton class. And i gave my answer as </p>
  
  <pre><code>public class Singleton {
  
      private static Singleton ref;
  
      private Singleton() {
      }
  
      public static Singleton getInstance() {
          if (ref == null) {
              ref = new Singleton();
          }
          return ref;
      }
  }
  </code></pre>
  
  <p>suddenly he told me this is old way of writing the class. Can any one please help me why he told like that. </p>