I guess that would depend on your definition of "singleton". If you defer object creation to some mechnism external to the "singleton" class, you could let that mechanism cache the first instance it creates and have it return that instance upon consecutive calls. Which is kind of how Spring handles "singleton" beans. Ofcourse this definition of a "singleton" is radically different from the traditional design pattern, and ouside the scope of such a mechanism the bean could not be considered a "singleton" at all. [ June 05, 2008: Message edited by: Jelle Klap ]
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Originally posted by Natesan Prabhakaran: Why not we use anonymous class to create singleton, by default its private constructor. I dont know please tell me.
I don't understand the question. Perhaps you can show us some code?
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