-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBookDemo.java
More file actions
35 lines (29 loc) · 877 Bytes
/
BookDemo.java
File metadata and controls
35 lines (29 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// A short package demonstration.
package BookPack;
class Book {
private String title;
private String author;
private int pubDate;
Book(String t, String a, int d) {
title = t;
author = a;
pubDate = d;
}
void show() {
System.out.println(title);
System.out.println(author);
System.out.println(pubDate);
System.out.println();
}
}
class BookDemo {
public static void main(String args[]) {
Book books[] = new Book[5];
books[0] = new Book("Java: A Beginner's Guide", "Schildt", 2005);
books[1] = new Book("Java: The Complete Reference", "Schidt", 2005);
books[2] = new Book("The Art of Java", "Schildt and Holmes", 2003);
books[3] = new Book("Red Storm Rising", "Clancy", 1996);
books[4] = new Book("On the Road", "Kerouac", 1955);
for(int i = 0; i < books.length; i++) books[i].show();
}
}