Saturday, 27 January 2018

What is Singleton design pattern? How to create Singleton class?

..In Java the Singleton pattern will ensure that there is only one instance of a class is created in the Java Virtual Machine. It is used to provide global point of access to the object.
…. In terms of practical use Singleton patterns are used in logging, caches, thread pools, configuration settings, device driver objects.
create singleton class———
1.Make constructor as private.

2.Write a static method that has return type object of this singleton class. Here, the concept of Lazy initialisation in used to write this static method.

No comments:

Post a Comment