Quiz · Final project · lesson 4 of 4
Quiz — everything together
What does the program print?
import java.util.List;
public class Main {
public static void main(String[] args) {
List<Book> books = List.of(new Book("Dune", 1965),
new Book("Hamlet", 1603), new Book("Emma", 1815));
System.out.println(books.stream()
.filter(b -> b.year() > 1700)
.map(Book::title)
.toList());
}
}
record Book(String title, int year) {}