Results 1 to 2 of 2
- 11-18-2008, 04:03 PM #1Member
- Join Date
- Nov 2008
- Rep Power
How to get objects to interact without inheritence in separate classes?
I have 3 classes inheriting from each other. so class SpecialAccount inherits from Account and class GoldAccount ingerits from SpecialAccount. I have produced a new class Customers that needs to use the exisiting 'accounts' objects and their values but cannot find any material on how to do this without inheritence.:mad: All classes are public - so it should be possible.
So I would need to do something like cast the objects to a new reference?
or get and set the objects?
Im lost :confused:
- 11-18-2008, 04:48 PM #2
no you can access them from your customers class by doing Package.Class.Method
So say you had an array of customers within your GoldAccount class and you needed to check if a customer was in that array. It would be something along the lines of
Customers customers = GoldAccount.getCustomers();
getCustomers() has to be a static method within GoldAccount(a public or protected class if their in the same package)
- By this.that in forum New To JavaReplies: 4Last Post: 08-07-2008, 10:09 PM
- By Java Tip in forum java.langReplies: 0Last Post: 04-12-2008, 08:42 PM
- By yalla in forum New To JavaReplies: 1Last Post: 03-30-2008, 06:11 AM
- By Aleve in forum New To JavaReplies: 8Last Post: 12-31-2007, 08:05 AM
- By romina in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 05:26 AM