public class StudentManger {
private static StudentManger sm=new StudentManger();
private StudentManger(){};
public static StudentManger newInstance()
{
return sm;
}
}
LZ这是单列模式,至于你说的,来增删改成,什么数据库?还是直接用数组?你这需求不明确啊! ------解决方案-------------------- public class StudentManger {
private static StudentManger sm = new StudentManger();
private StudentManger() {
};
private Student student;
public void setStudent(Student student) {
this.student = student;
}
public static StudentManger getInstance() {
return sm;
}
public void add() {
System.out.println(student.getName());
}
public void modify() {
}
public void delete() {
}
public Student query() {
return null;
}
public static void main(String[] args) {
StudentManger studentManger = StudentManger.getInstance();
Student student1 = new Student("ooo");
studentManger.setStudent(student1);