Java Programming Tutorials

Java programming tutorials with many code examples!

Java Singleton – enum implementation

Java Singleton – enum implementation

Singleton as enum is very simple to implement and very safe at the same time thanks to language guarantees for enum instantiation and serialization.

Read More

Share with the World!

Java Singleton – on demand initialization

Java Singleton – on demand initialization

On demand initialization is extension of static final implementation. It will prevent eager initialization of the singleton instance, when other fields are accessed. Also known as Bill Pugh‘s solution.

Read More

Share with the World!

Java Singleton – static final implementation

Java Singleton – static final implementation

It is the simplest and most common implementation of Singleton Design Pattern in Java. In this post we’ll show how to implement it correctly and explain why it works.

Read More

Share with the World!