I am trying to write an ArrayList of objects to a text file. I would also like it to only write the first 43 lines. My code so far:
ArrayList<seat> seats1 = new ArrayList<>();
try {
FileWriter writer = new FileWriter(
"seats.txt");
for (int i = 0; i < 43; i++) {
writer.write(seats1.get(i).toString()
+ System.lineSeparator());
}
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
This writes the first 43 lines of the array but it outputs the object hashcode rather than a string.