【发布时间】:2010-12-09 00:55:42
【问题描述】:
我创建了一个由自定义对象组成的数组列表。基本上,用户将创建一个类,并且每次创建一个类时,都会将一个新的 Lecture(我的自定义对象)添加到数组列表中。我需要保存生成的数组列表,这样即使重新启动应用程序也会保存用户的类。
据我了解,我必须使我的课程可序列化。但我究竟该怎么做呢?然后,一旦它被序列化了,我该怎么办?
public class Lecture{
public String title;
public String startTime;
public String endTime;
public String day;
public boolean classEnabled;
public Lecture(String title, String startTime, String endTime, String day, boolean enable){
this.title = title;
this.startTime = startTime;
this.endTime = endTime;
this.day = day;
this.classEnabled = enable;
}
//Getters and setters below
【问题讨论】: