Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1.  
  2. public class PassObject
  3. {
  4. public static void main(String[] args)
  5. {
  6. //Create an InventoryItem object
  7. InventoryItem item = new InventoryItem("Wrench", 20);
  8.  
  9. //Pass the object to the DisplayItem method.
  10. displayItem(item);
  11. }
  12. //the following method accepts an InventoryItem
  13. //object as an argument and displays its contents
  14.  
  15. public static void displayItem(InventoryItem i)
  16. {
  17. System.out.println("Description; " + i.getDescription());
  18. System.out.println("Units: " + i.getUnits());
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement