我目前正在建立一个地址簿。我将每个条目作为对象存储到地址簿中。我的问题是我无法弄清楚如何从对象中获取任何特定变量并显示它。比如 firstName 之类的。它应该将变量写入一个文件,该文件将在程序再次启动时加载到数组中。
class ExitListener implements ActionListener{
public void actionPerformed(ActionEvent e){
try {
PrintWriter output = new PrintWriter(FILE);
ListIterator it1 = set.listIterator();
while (it1.hasNext()){
}
output.flush();
output.close();
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.exit(0);
}
}