|
| Total Answers and Comments: 5 |
Last Update: September 27, 2006 |
|
| | |
|
Submitted by: Vinoth Senthill With the Singleton design pattern you can: Ensure that only one instance of a class is created Provide a global point of access to the object Allow multiple instances in the future without affecting a singleton class's clients //Sample Code public class SingleInstance { private static SingleInstance ourInstance = new SingleInstance(); public static SingleInstance getInstance() { if(null==ourInstance){ ourInstance= new SingleInstance(); } return ourInstance; } private SingleInstance() { } }
Above answer was rated as good by the following members: shilpad | Go To Top
|