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

What is private protected in java?

555


What is method and methodology?

610


Where to store local variables?

587


What does arrays sort do in java?

546


What is keyword and identifier?

645






What is java in detail?

563


What is string [] java?

530


Is finalize() similar to a destructor?

556


Difference between static synchronization vs. Instance synchronization?

568


What is a map? What are the implementations of map?

574


What are the two parts of a conditional statement?

518


Given a singly linked list, how will you print out its contents in the reverse order? Can you do it with consuming any extra space?

609


What are the default and parameterized constructors?

559


What are void methods?

576


What is formatted output in java?

503