You need to implement the Iterable
interface, which means you need to implement the iterator()
method. In your case, this might look something like this:
public class BookList implements Iterable<Book> {
private final List<Book> bList = new ArrayList<Book>();
@Override
public Iterator<Book> iterator() {
return bList.iterator();
}
...
}