I am currently building an address book. I am storing each entry into the address book as an object. My problem is that I cannot figure out how to get any specific variable from an object and display it. Such as the firstName for example. It’s supposed to write the variables to a file which will be loaded into the array when the program is started again.
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);
}
}
I’m going to have to apply my psychic debugging powers here, as you haven’t presented any code. My guess is that you’ve got a variable like this:
If you use generics, this becomes: