Results 1 to 2 of 2
  1. #1
    TheCase is offline Member
    Join Date
    Oct 2011
    Rep Power

    Default Printing results from another class


    I have two classes Books and Customers

    the idea is a book shop I'm trying to get each object on the Book class to match a object on the Customers class so for example I can call a print customer method on the Book class to see what customer bought that book but how do I link two classes together and get the fields from one class to another?


  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: Printing results from another class

    Usually classes hold variables of other types or collections such as arrays, Maps, or Lists such as ArrayLists of other types, and the containing class can then call the methods of the contained objects.

    For instance, a BookStore class could hold an ArrayList of Book objects, and a customer could have a ShoppingCart filled with some of these Books (also held in an ArrayList).

Similar Threads

  1. Replies: 9
    Last Post: 08-19-2011, 12:59 AM
  2. Vector results need to be available to another class
    By Paul_White in forum New To Java
    Replies: 6
    Last Post: 05-07-2011, 07:45 PM
  3. printing string backwards and printing every other
    By droidus in forum New To Java
    Replies: 22
    Last Post: 03-10-2011, 09:17 AM
  4. Sometimes get the right results sometimes dont
    By Battlefeldt in forum New To Java
    Replies: 0
    Last Post: 12-18-2009, 01:03 AM
  5. Java results in Excel
    By puk284 in forum New To Java
    Replies: 1
    Last Post: 04-21-2009, 04:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts