Reference : Effective Java Edition 2
There are two ways to implement Singleton pattern in Java
1. public final instance field or static factory method to create/get instance.
2. if you are using Java >= 1.5. You can use Enum for Singleton– this way you get Singleton functionality easily and you don't need to worry about the Serialization.
Sample Code:
and can use in the following way.
cheers.... :-)
wow!.. thanks for sharing this!
ReplyDelete