Commit 52b93d86 authored by Suresh Kumar's avatar Suresh Kumar

Merge branch 'features/singleton' into 'develop'

Refactor Signleton

See merge request !22
parents 5d0ac557 1cd4ded5
package singleton.com; package singleton.com;
public class Student { public class Student {
static Student st = new Student(); static Student st = new Student();
private Student(){ private Student(){
System.out.println("Simple Singleton Created "); System.out.println("Simple Singleton Created ");
} }
static Student getInstance(){ static Student getInstance(){
return st; return st;
} }
......
package singleton.com; package singleton.com;
public class Test { public class Test {
public static void main(String [] args){ public static void main(String [] args){
Student s1 = Student.getInstance(); Student s1 = Student.getInstance();
Student s2 = s1; Student s2 = s1;
System.out.println(s1==s2); 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