Crenox

Books Program

Jan 28th, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. package samkough.main;
  2.  
  3. public class Books
  4. {
  5. public static void main(String args[])
  6. {
  7. BooksTestDrive[] b = new BooksTestDrive[3];
  8. int x = 0;
  9.  
  10. b[0] = new BooksTestDrive();
  11. b[0].title = "The Grapes of Java";
  12. b[0].author = "bob";
  13.  
  14. b[1] = new BooksTestDrive();
  15. b[1].title = "The Java Gatsby";
  16. b[1].author = "sue";
  17.  
  18. b[2] = new BooksTestDrive();
  19. b[2].title = "The Java Cookbook";
  20. b[2].author = "ian";
  21.  
  22. while(x < 3)
  23. {
  24. System.out.println(b[x].title);
  25. System.out.println(" by ");
  26. System.out.println(b[x].author);
  27. x += 1;
  28. }
  29. }
  30. }
  31. ------------------------------------------------------------------------------------------------------------------
  32. package samkough.main;
  33.  
  34. public class BooksTestDrive
  35. {
  36. String title;
  37. String author;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment