Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package samkough.main;
- public class Books
- {
- public static void main(String args[])
- {
- BooksTestDrive[] b = new BooksTestDrive[3];
- int x = 0;
- b[0] = new BooksTestDrive();
- b[0].title = "The Grapes of Java";
- b[0].author = "bob";
- b[1] = new BooksTestDrive();
- b[1].title = "The Java Gatsby";
- b[1].author = "sue";
- b[2] = new BooksTestDrive();
- b[2].title = "The Java Cookbook";
- b[2].author = "ian";
- while(x < 3)
- {
- System.out.println(b[x].title);
- System.out.println(" by ");
- System.out.println(b[x].author);
- x += 1;
- }
- }
- }
- ------------------------------------------------------------------------------------------------------------------
- package samkough.main;
- public class BooksTestDrive
- {
- String title;
- String author;
- }
Advertisement
Add Comment
Please, Sign In to add comment