This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes why fields can't be overidden????? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why fields can Watch "why fields can New topic
Author

why fields can't be overidden?????

rahul mehra
Ranch Hand

Joined: Aug 20, 2007
Posts: 33
why fields of superclass can't be overidden??? by a subclass


Thanks
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
The answer to this question, as to so many "why" questions, is "because the Java Language Specification says so".

Overriding is to do with run-time polymorphism. The Java language only implements run-time polymorphism for instance methods, not for fields or static methods. That's a choice the language designers made. They could have chosen differently, though in this case I think they chose well.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
jQuery in Action, 2nd edition
 
subject: why fields can't be overidden?????
 
Similar Threads
Calling Overridden methods and overshadowed variables
Why Static is allowed with Final
Calling Overridden methods and overshadowed variables
Why it is illegal to use abstract and static modifiers together in method declaration ?
static methods can't be overidden why