Question: Write in Java Use streams to get the unique surnames in uppercase of the first 10 book authors that are 50 years old or older.
Write in Java
Use streams to get the unique surnames in uppercase of the first 10 book authors that are 50 years old or older.
Assume that a variable 'library' is defined as an ArrayList. Each Element in the arraylist, representing a book, is an object from a Book class. The Book class has the book's name (a string), book ISBN number (a string), and the author as data fields (an object from the Author class). The Book class has a method getAuthor to return the author of the book.
The Author class holds the author's first name. last name, age as data fields. The Author class also has methods to return the data fields (getFirstName to return the first name, getLastName to return the last name, and getAge to return the age).
- define the Author class and Book class
- create the library as an ArrayList and add 20 books to the arraylist
- using stream to get the unique surnames in uppercase of the first 10 book authors that are 50 years old or older.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
