Results 1 to 9 of 9

Thread: [RESOLVED] (was being dumb) - Type casting a class?

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Location
    midewest u.s.
    Posts
    275

    [RESOLVED] (was being dumb) - Type casting a class?

    Is there a way in Java to type cast an array of a super class into the subclass?

    Example:

    I have a class person, account and checking. Account inherits from person, checking inherits from account. I am trying to make a little application to add/search through accounts created. I was going to make an array of the person class since it is the base class of the other 2, and then I was going to typecast each instance the way I needed to....

    if(people[0].getType()=="account")
    (account)people[0].AccountFunction();


    That type of thing. I get an error on the first ( before account saying expected statement.

    Any help would be appreciated
    Last edited by Tool; Oct 13th, 2005 at 05:53 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width