I have Book
and BookList
classes. BookList
is something like this:
public class BookList
{
private final List<Book> bList = new ArrayList<Book>();
public int size() { return bList.size(); }
public boolean isEmpty() { ... }
public boolean contains(Book b) { ... }
public boolean add(Book b) { ... }
public boolean remove(Book b) { .. }
public void clear() { ... }
public Book get(int index) { ... }
}
In my main class I want to print titles of books with in a for each loop:
for(Book b : bList)
{
b.print();
}
Eclipse says:
Can only iterate over an array or an instance of java.lang.Iterable
How can I get this working?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…