Quick actions

cmd+k|ctrl+k

Navigation

Languages

Singleton

Snippet info

Language

Java

Visibility

public

Author

1ndroidbella

Created

2019-08-01T21:03:42Z

Updated

2019-08-03T21:01:32Z

//@clashbyte
class Main {
    public static void main(String[] args) {
        
        System.out.println("=========not a Singleton==========="); 

        Student student1=new Student();
        System.out.println(student1.hashCode()); // 1252169911
        Student student2=new Student();
        System.out.println(student2.hashCode()); // 2101973421
        
        System.out.println("=========Singleton==========="); 

        
        Singleton singleton1=Singleton.getInstance();
        System.out.println(singleton1.hashCode());  
        Singleton singleton2=Singleton.getInstance();
        System.out.println(singleton2.hashCode()); 

    }
}

INFO