-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBooksTestDrive.java
34 lines (28 loc) · 921 Bytes
/
BooksTestDrive.java
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
public class BooksTestDrive {
public static void main(String[] args) {
int x = 0;
//creating a book arrays object with length 3.
Books[] myBooks = new Books[3];
myBooks[0] = new Books();
myBooks[1] = new Books();
myBooks[2] = new Books();
// assign title to books string
myBooks[0].title = "The Grapes of Java";
myBooks[1].title = "The Java Gatsby";
myBooks[2].title = "The Java CookBook";
//assign author to books string
myBooks[0].author = "Diego";
myBooks[1].author = "Cristine";
myBooks[2].author = "David";
while (x < myBooks.length) {
System.out.println(myBooks[x].title);
System.out.println("by ");
System.out.println(myBooks[x].author);
x++;
}
}
static class Books {
String title;
String author;
}
}