Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge (ArrayList) | Basic Data Structures
Java Data Structures
course content

Зміст курсу

Java Data Structures

Java Data Structures

1. Basic Data Structures
2. Additional Data Structures
3. Map
4. enum & Stream API

bookChallenge (ArrayList)

Let's Practice!

Your task is to implement a library management system in Java. A Book class has already been created for you with all the fields, setters, and getters. You can familiarize yourself with it in the Book class.

Also, a LibraryDemo class has been created for you, which tests all the methods from the Library class.

Create a class Library that represents a collection of books. Use an ArrayList to store instances of the Book class.

Implement the following methods in the Library class:

  • addBook(Book book): Adds a book to the library;
  • removeBookById(int id): Removes a book from the library based on the unique identifier;
  • findBooksByAuthor(String author): Returns a list of books by the specified author;
  • findBooksPublishedAfterYear(int year): Returns a list of books published after the specified year;
  • displayAllBooks(): Displays information about all the books in the library on the screen.

After that, you need to go to the LibraryDemo class and run it. It will test the correctness of the methods you implemented.

Learning how to work with GitHub assignments can be found here .

Instructions and tips on how to solve this task are outlined on GitHub.

If you're having trouble with solving and understanding the task, I suggest you think more carefully because programmers try to solve problems independently. It's the best way to learn.

But if you are stuck, you can see solutions for this task here. Don't forget to rewrite this solution for yourself and analyze everything to master this topic truly:

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 3
some-alt