File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes question about sub class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "question about sub class" Watch "question about sub class" New topic

question about sub class

John Batista

Joined: May 22, 2011
Posts: 20
my code:

the root class

the node class

the main class

In the screenshot, the x is from the node class, while name() that's run belongs to the root class. what is this inconsistency? Thanks
John Batista

Joined: May 22, 2011
Posts: 20
OK, never mind. after googling, apparently just have to live with that. That's the rule. nothing can be done about it. Thanks
Vishwanath Krishnamurthi
Ranch Hand

Joined: Jun 04, 2007
Posts: 331
Hi John,

Overriding is only for methods. Not for instance fields.

PS: You might find it easier to paste the code and use code tags, than to post screenshots

Pranav Raulkar
Ranch Hand

Joined: Apr 20, 2011
Posts: 73

Hi John,
Similar question has been asked recently by a fellow java rancher. Refer to this post
I agree. Here's the link:
subject: question about sub class
It's not a secret anymore!