饿汉单例模式:
class Student{
private static Student s = new Student();
private Student(){
}
public static Student getInstance(){
return s;
}
}
//懒汉单例模式
class Person{
private static Person p;
private person(){
}
public static Person getinstance(){
if(p==null){
p=new Person();
}
return p;
}
}