I need help with saving an array to a text file. So I have the following array
private Passenger[] queueArray = new Passenger[30];
and this is the class that I have
public class Passenger
{
private String firstName;
private String surname;
private int secondsInQueue;
Passenger(String firstName, String surname)
{
this.firstName = firstName;
this.surname = surname;
secondsInQueue = 0;
}
public String getName()
{
return firstName + " " + surname;
}
public void setName(String firstName, String surname)
{
this.firstName = firstName;
this.surname = surname;
}
public Integer geSeconds()
{
return secondsInQueue;
}
public void setSecondsInQueue(Integer SecondsInQueue)
{
this.secondsInQueue = SecondsInQueue;
}
public void display()
{
System.out.println(firstName + " " + surname + " " + secondsInQueue);
}
}
I need to save the first name and the surname of the passengers to a text file. And then I need to read the file back to the array.
I am literally so stuck... Any help would be appreciated.
Thank You!