Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. public List<Book> filterBooks(List<Book> readingList, String author)
  2. {
  3. // Remove all Books from the readingList that are not
  4. // written by the given author. Return the resulting List
  5. List<Book> newList = new ArrayList<Book>();
  6. for(int i = 0; i < readingList.size(); i++)
  7. {
  8. if(author.equals(readingList.get(i).getAuthor()))
  9. {
  10. newList.add(readingList.get(i));
  11. }
  12. }
  13. return newList;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement