我有一个类的数组列表,Room
它保存在类中Hostel
,我想将此数组列表写入文本文件。这样做最有效的方法是什么?
宿舍类
public class Hostel
{
private ArrayList < Room > rooms;
}
房间等级
abstract class Room
{
public Room(int newRoomNo, boolean newRoomEnSuite, int newRoomNights, String newRoomBooker)
{
roomNo = newRoomNo;
roomEnSuite = newRoomEnSuite;
roomBooking = "Booked";
roomNights = newRoomNights;
roomBooker = newRoomBooker;
}
}