|
-
Oct 8th, 2005, 03:34 PM
#1
Thread Starter
Hyperactive Member
[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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|