Results 1 to 2 of 2
- 11-18-2008, 05:03 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 3
- Rep Power
- 0
How to get objects to interact without inheritence in separate classes?
Hello,
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:
Thank you
- 11-18-2008, 05: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)
Similar Threads
-
I'm trying to add a separate dialog to a Java program...
By romina in forum AWT / SwingReplies: 3Last Post: 07-10-2015, 03:09 PM -
1 to 1 Objects
By this.that in forum New To JavaReplies: 4Last Post: 08-07-2008, 11:09 PM -
Hash table with separate chaining
By Java Tip in forum java.langReplies: 0Last Post: 04-12-2008, 09:42 PM -
[SOLVED] Problem with code - inheritence
By yalla in forum New To JavaReplies: 1Last Post: 03-30-2008, 07:11 AM -
Objects and Classes
By Aleve in forum New To JavaReplies: 8Last Post: 12-31-2007, 09:05 AM
Bookmarks