//java program to understand the concept of composition
class Library
{
//library can have no of books
//book does not exist without library
// so there is strong relationship it is called composition
Book b;
Library(String bookname)
{
b = new Book(bookname);
b.getBookInfo();
}
}
class Book
{
String bookname;
Book(String bookname)
{
this.bookname = bookname;
}
public void getBookInfo()
{
System.out.println(bookname);
}
}
public class Main
{
public static void main(String args[])
{
Library l = new Library("Hemlet");
}
}