Commit 1cd4ded5 authored by Suresh Kumar's avatar Suresh Kumar

Refactor Signleton

parent 71f84743
package singleton.com;
public class Student {
static Student st = new Student();
private Student(){
System.out.println("Simple Singleton Created ");
}
static Student getInstance(){
return st;
}
......
package singleton.com;
public class Test {
public static void main(String [] args){
Student s1 = Student.getInstance();
Student s2 = s1;
System.out.println(s1==s2);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment