Friday, May 8, 2009

Singleton

Singleton design patters are used where there is only one instance of an object is required.

Here is an example of singleton class.

public class singleton
{
private static singleton instance=null;
static public singleton getInstance()
{
if(instance==null)
instance=new singleton();
return instance;
}
private singleton()
{}
.
.
.
.
}

No comments: