as i know,we can't create a object outside a class because we are using a private constructor inside a class. can any one suggest me the exact definition of singleton with the the help of programming? kindly suggest me with the exact definition with programming!
The 'single'ton uses a single instance instead of two or more, for performance-related reasons.
There is a static method in the singleton class that any outside class can call. Inside that method the class instantiates an instance of its class, and returns it to the outside caller. That is how it is instantiated.
Why singleton? If you have one million transactions a day which can possibly create/instantiate one or more of a certain class, that can put a performance hit on you server. If a single instance can serve all those multi-million transactions, then you improve the resource statistics of your server by a big factor. You only instantiate one, instead of say 5 million! (Memory/resources speaking: what a relief!)
Note that in addition of only having one instance of a class, the Singleton pattern also provides a global access point (a static getter). This can lead to a nasty coupling problem. Fortunately there are alternative patterns that too only provide one instance, for example the Just Create One pattern.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus