Skip to content

Instantly share code, notes, and snippets.

@amitkma
Created August 20, 2019 14:53
Show Gist options
  • Save amitkma/0a98f804c04bb9bdb144f65db7cb3dc5 to your computer and use it in GitHub Desktop.
Save amitkma/0a98f804c04bb9bdb144f65db7cb3dc5 to your computer and use it in GitHub Desktop.
class Library…
public Book[] booksAuthoredBy(String arg) {
List allBooks = finder.findAll();
for (Iterator it = allBooks.iterator(); it.hasNext();) {
Book book = (Book) it.next();
if (!book.getAuthor().equals(arg)) it.remove();
}
return (Book[]) allBooks.toArray(new Book[allBooks.size()]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment