Singleton
//@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