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

    Default Printing results from another class

    Hi,

    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?

    Thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    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, 01: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, 08:45 PM
  3. printing string backwards and printing every other
    By droidus in forum New To Java
    Replies: 22
    Last Post: 03-10-2011, 10:17 AM
  4. Sometimes get the right results sometimes dont
    By Battlefeldt in forum New To Java
    Replies: 0
    Last Post: 12-18-2009, 02:03 AM
  5. Java results in Excel
    By puk284 in forum New To Java
    Replies: 1
    Last Post: 04-21-2009, 05: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
  •