Skip to content

Instantly share code, notes, and snippets.

@Harishraj16
Created March 18, 2024 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Harishraj16/56022e4019d4105925b5089b040fa270 to your computer and use it in GitHub Desktop.
Save Harishraj16/56022e4019d4105925b5089b040fa270 to your computer and use it in GitHub Desktop.
public class Library<T extends Book> {
private List<T> books = new ArrayList<>();
public void addBook(T book) {
books.add(book);
}
public T borrowBook() {
if (!books.isEmpty()) {
return books.remove(0);
} else {
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment