Singleton

Are Java Enums Really the Best Singletons?

We must have heard multiple times that enums are always the best choice for implementing singleton design pattern in java. Are they really the best? If it is then how is it better than other available techniques? Let’s find out. Writing a singleton implementation is always tricky. I already discussed a couple of methods (including …

Singleton Pattern (with Example)

To create a singleton, make the constructor private, disable cloning, disable extension and create a static variable to house the instance

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.