Results 1 to 2 of 2
- 10-30-2011, 06:08 PM #1Member
- Join Date
- Oct 2011
- Rep Power
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?
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).
- By kingkongjaffa in forum New To JavaReplies: 9Last Post: 08-19-2011, 01:59 AM
- By Paul_White in forum New To JavaReplies: 6Last Post: 05-07-2011, 08:45 PM
- By droidus in forum New To JavaReplies: 22Last Post: 03-10-2011, 10:17 AM
- By Battlefeldt in forum New To JavaReplies: 0Last Post: 12-18-2009, 02:03 AM
- By puk284 in forum New To JavaReplies: 1Last Post: 04-21-2009, 05:13 AM