Save India From Corruption - Anna Hazare.
SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
Save India From Corruption - Anna Hazare.
SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
As the name implies, you wish to have only one instance of the object at the one time when you implement a class as a Singleton.
Save India From Corruption - Anna Hazare.
SCJP 6, OCMJD 6, OCPJWSD 6
I no good English.
Save India From Corruption - Anna Hazare.
Save India From Corruption - Anna Hazare.
Ravi Kiran V wrote:Actually My question is "Why we need to have only one instance for a Singleton class"??
Why cant we leave this with a public constructor , so that if whenever any class requires this Object's data just instainate with new keyword and call a method on it
For example
In another class :
what is the problem with this ??
OCPJP 6
Vinoth Kumar Kannan wrote:Ravi, see if this helps....how would you instantiate the java.util.Calendar class - which we all regularly use?!
Like this,right?
The Java designers decided to make Calendar class a singleton class...
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Paul Clapham wrote:
And it's perfectly reasonable to have two Calendar objects. They could contain different information, for example.
OCPJP 6
Vinoth Kumar Kannan wrote:
Paul Clapham wrote:
And it's perfectly reasonable to have two Calendar objects. They could contain different information, for example.
Is it possible to create 2 instances of a Calendar?? I've never seen such code! How to create 2 of them? Enlighten me please.
Save India From Corruption - Anna Hazare.