Singleton design pattern is to be used when we want to ensure that only 1 instance of the class should be created. For e.g if we have only 1 liscence for something. Is the below the right way to implement it ?
Monica Shiralkar wrote:And how would rest of the code be?
That is the bare minimum you need to implement an enum singleton in Java. Obviously, if your singleton has some behavior that it needs to exhibit, the rest of the class would be whatever is needed to implement that behavior.
The best ideas are the crazy ones. If you have a crazy idea and it works, it's really valuable.—Kent Beck