Classes & Objects (Cont)
Lesson 27Author : 🦒
Last Updated : October, 2017
Code
class Book{
public String title;
public String author;
}
public class App{
public static void main(String [] args){
Book book1 = new Book();
book1.title = "Harry Potter";
book1.author = "JK Rowling";
System.out.println(book1.title);
Book book2 = new Book();
book2.title = "Lord of the Rings";
book2.author = "JRR Tolkien";
System.out.println(book2.title);
}
}