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 why fields can't be overidden????? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why fields can Watch "why fields can New topic

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

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.
I agree. Here's the link:
subject: why fields can't be overidden?????