How to implement Singleton

Answer Posted / supraja

The Singleton pattern
In Design Patterns, the authors describe the Singleton
pattern like this:

Ensure a class has only one instance, and provide a global
point of access to it.



The figure below illustrates the Singleton design pattern
class diagram.



Singleton class diagram

As you can see from the figure above, there's not a whole
lot to the Singleton design pattern. Singletons maintain a
static reference to the sole singleton instance and return
a reference to that instance from a static instance()
method.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do I need java on my computer?

756


Explain constructors and types of constructors in java.

854


What is r * in math?

759


What do you mean by platform independence?

818


What are basic data types?

809


Can finally block be used without a catch?

768


What is method and methodology?

890


What is a memory leak in java?

807


In the below example, what will be the output?

817


What is the use of string and stringbuffer?

795


How to set the permissions to a file in java?

784


Is java hard to learn?

721


Why a dead thread occurs?

796


How would you use Bubble Sort to sort the number of elements?

836


what is thread? : Java thread

784