design-patterns

This repository contains code examples in Java for all the 23 design patterns coined by GoF

View project on GitHub

Singleton Pattern

This repository contains code examples for the types of implementations for Singleton Pattern

S.No Pattern Pros Cons When to use?
1 EagerInitialization Very simple to implement 1) May lead to resource wastage. Because instance of class is created always, whether it is required or not. 2) CPU time is also wasted in creation of instance if it is not required. 3) Exception handling is not possible.  
2 Static Block