Results 1 to 2 of 2
  1. #1
    Fliz is offline Member
    Join Date
    Nov 2008
    Rep Power

    Unhappy 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:
    Thank you

  2. #2
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Houston, TX & Flint, MI
    Rep Power


    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

  1. Replies: 3
    Last Post: 07-10-2015, 02:09 PM
  2. 1 to 1 Objects
    By this.that in forum New To Java
    Replies: 4
    Last Post: 08-07-2008, 10:09 PM
  3. Hash table with separate chaining
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-12-2008, 08:42 PM
  4. [SOLVED] Problem with code - inheritence
    By yalla in forum New To Java
    Replies: 1
    Last Post: 03-30-2008, 06:11 AM
  5. Objects and Classes
    By Aleve in forum New To Java
    Replies: 8
    Last Post: 12-31-2007, 08:05 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