Today in my interview one interviewer asked me to write a Singleton class. And i gave my answer as
public class Singleton { private static Singleton re
From What is an efficient way to implement a singleton pattern in Java?
Use an enum:
public enum Foo { INSTANCE; }
Joshua Bloch explained this approach in his book 'Effective Java'
Also check out The better Java singleton pattern nowadays?