Heading

Wednesday, April 3, 2013

Singleton Program In JAVA


public class Singleton {
private static Singleton instance;
private Singleton()
{
   
}
public static Singleton getInstance() {
    if (instance==null)
    instance = new Singleton();
    return instance;
   
}
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
Singleton s1=new Singleton();
Singleton s2=new Singleton();
Singleton s3=new Singleton();
System.out.println("Ist object:"+s1.getInstance());
System.out.println("2nd object:"+s2.getInstance());
System.out.println("3rd object:"+s3.getInstance());

    }

}
Can any One Guess OutPut of this Program