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 the best way to findout the time/memory consuming process?

550


How do you sort in java?

581


What is a null point?

550


Why is the type for real numbers called double?

539


What is the difference between a factory and abstract factory pattern?

680






What is class array in java?

501


What is the purpose of declaring a variable as final?

480


how many types of Inheritance?

641


What is byte code and why is it important to java’s use for internet programming?

588


Which sort is best in java?

520


Can a list be null in java?

533


Is set ordered?

533


Write a method that will remove given character from the string?

567


What do you mean by order of precedence and associativity?

539


What is natural ordering in java?

517