When we try to print an ArrayList all at once we get
getClass().getName() + "@" + Integer.toHexString(hashCode())
In order to print the individual values, we need to change the toString() method in the class containing the setters/getters.
Add the following:
If your ArrayList is (snippets from my code):
ArrayList<Reservation> reservationsList = new ArrayList<Reservation>();
Reservation reservation;
reservation = new Reservation();
reservation.setDescription(cursor.getString(1));
// Does this work with recurring apps?
reservation.setStartDate(new Date(cursor.getLong(3)));
reservation.setEndDate(new Date(cursor.getLong(4)));
reservation.setLocation(cursor.getString(5));
reservationsList.add(reservation);
//Add the overriden toString() method
@Override
public String toString() {
return ("Description:" + "\n" + this.getDescription() + "\n"
+ "Start Date:" + "\n" + this.getStartDate() + "\n"
+ "End Date:" + "\n" + this.getEndDate() + "\n"
+ "Location :" + "\n" + this.getLocation());
}
getClass().getName() + "@" + Integer.toHexString(hashCode())
In order to print the individual values, we need to change the toString() method in the class containing the setters/getters.
Add the following:
If your ArrayList is (snippets from my code):
ArrayList<Reservation> reservationsList = new ArrayList<Reservation>();
Reservation reservation;
reservation = new Reservation();
reservation.setDescription(cursor.getString(1));
// Does this work with recurring apps?
reservation.setStartDate(new Date(cursor.getLong(3)));
reservation.setEndDate(new Date(cursor.getLong(4)));
reservation.setLocation(cursor.getString(5));
reservationsList.add(reservation);
//Add the overriden toString() method
@Override
public String toString() {
return ("Description:" + "\n" + this.getDescription() + "\n"
+ "Start Date:" + "\n" + this.getStartDate() + "\n"
+ "End Date:" + "\n" + this.getEndDate() + "\n"
+ "Location :" + "\n" + this.getLocation());
}