Exercise 101: The library printBooks()

81 views
Skip to first unread message

Alberto

unread,
Feb 1, 2017, 6:12:06 PM2/1/17
to mooc.fi
Hi,

I'm having problems with week 6 exercise 101.2 on course OOP part 1.

When I iterate over the array items (created in the Library class, holding all the Book objects) I get an empty output. I thought that by calling the toString() method, implemented in the Book class, I would easily get to print all the info of all the books stored in the array.
If I instead use "sout" I get the expected output.
What am I missing?

public void printBooks(){
       
       
for (Book obj : this.items){
            obj
.toString(); //this works instead: System.out.println(obj);
       
}
       
   
}


Best regards,

Alberto
Reply all
Reply to author
Forward
0 new messages