import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Book{
    String title;
    String author;
    Book(String title,String author){
        this.title=title;
        this.author=author;
    }
}

class Library{
    ArrayList<Book> books=new ArrayList<>();
    Library(ArrayList<Book> books){
        this.books=books;
    }
    void display(){
        for(Book book:books){
            System.out.println(book.title+" "+book.author);
        }
    }
}
class Main {
    public static void main(String[] args) {
      Book book1 = new Book("Head First Design Patterns", "Eric Freeman");
      Book book2 = new Book("Clean Code", "Robert C. Martin");
      ArrayList<Book> booklist=new ArrayList<>();
      booklist.add(book1);
      booklist.add(book2);
      Library lb=new Library(booklist);
      lb.display();
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: