permaculture playing cards*
The moose likes Java in General and the fly likes Singleton Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Singleton Object" Watch "Singleton Object" New topic
Author

Singleton Object

Nimmy
Greenhorn

Joined: Apr 12, 2005
Posts: 13
What�s the difference between a singleton class and a static class?

If the answer is static class is one approach to make a class �Singleton� I have one doubt.

If the constructor is public I can create more than one instance then how does it work like a singleton?
Neeraj Dheer
Ranch Hand

Joined: Mar 30, 2005
Posts: 225
i think this is what you are looking for.

please go through it. that should solve most of your queries.
Sivalingan
Greenhorn

Joined: May 10, 2005
Posts: 4
Please go thou the following link for more details about design pattenrs

http://www.javacamp.org/designPattern/index.html

www.allapplabs.com
Edwin Keeton
Ranch Hand

Joined: Jul 10, 2002
Posts: 214

If you were trying to implement Singleton with a "static class" (meaning all members of the class are static), you would not use a public constructor. You would implement an unused private constructor so there would be no public default constructor. Ane while you were at it you would make the class final to prevent a subclass creating an instance.


SCJP, SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Singleton Object
 
Similar Threads
2 different types of singleton
"static class" Vs "Singleton"
what is the use of this " static A a = new A() "
Should the Singleton instance be a final variable?
constructors marked private