Crenox

Hobbits Program

Jan 29th, 2014
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. package samkough.main;
  2.  
  3. public class Hobbits
  4. {
  5. public static void main(String args[])
  6. {
  7. HobbitsTestDrive[] h = new HobbitsTestDrive[3];
  8. int z = 0;
  9.  
  10. while (z < 2)
  11. {
  12. z = z + 1;
  13. h[z] = new HobbitsTestDrive();
  14. h[z].name = "bilbo";
  15.  
  16. if (z == 1)
  17. {
  18. h[z].name = "frodo";
  19. }
  20.  
  21. if (z == 2)
  22. {
  23. h[z].name = "sam";
  24. }
  25. System.out.println(h[z].name + " is a ");
  26. System.out.println("good Hobbit name");
  27. }
  28. }
  29. }
  30. ------------------------------------------------------------------------------------------------------------------
  31. package samkough.main;
  32.  
  33. public class HobbitsTestDrive
  34. {
  35. String name;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment