On 4=D4=C219=C8=D5, =CF=C2=CE=E75=CA=B141=B7=D6, thufir
<hawat.thu...@[EMAIL PROTECTED]
> wrote:
> My understanding is that the toString method for an ArrayList will call
> the respective toString method for each element of the ArrayList.
>
> However, in the below code, calling guests.toString() gives no output.
>
> I think that I must be doing something wrong that the printGuests method
> must even exist, but I'm not sure what -- I just want to print all the
> guests.
>
> thufir@[EMAIL PROTECTED]
> thufir@[EMAIL PROTECTED]
cat src/a00720398/labs/Lab2.java
>
> package a00720398.labs;
> im****t a00720398.data.*;
> im****t java.util.*;
>
> public class Lab2
> {
>
> private static Guests guests =3D new Guests();
>
> public static void loadGuests() {
> for (int i=3D0; i<9; i++) {
> Guest guest =3D new Guest();
> guests.add(guest);
> }
> }
>
> public static void printGuests() {
> for (Guest guest : guests) {
> System.out.println(guest);
> }
> }
>
> public static void main (String[] args)
> {
> loadGuests();
> printGuests(); //prints out the guests
> //guests.toString; //gives no output at
all.why?
> }
>
> }
>
> thufir@[EMAIL PROTECTED]
> thufir@[EMAIL PROTECTED]
cat src/a00720398/data/Guests.java
>
> package a00720398.data;
> im****t java.util.*;
>
> public class Guests extends ArrayList <Guest>
> {
>
> }
>
> thufir@[EMAIL PROTECTED]
> thufir@[EMAIL PROTECTED]
>
> thanks,
>
> Thufir
do you overwrite the toString method ,if not it will return the
address of object in the main memery.so overwrite the toString method


|