Why is method invocation in Java polymorphic but field access isn't?

John Mitchell

This general area is covered in Section 15.11.1 of the JLS. The designers of the Java programming language feel that the lack of dynamic lookup on field accesses provides greater run-time efficiency. In addition, if people want dynamic lookup on fields then they can easily use an accessor (aka "getter") instance method instead of direct field access. I.e., they leave the tradeoff up to the programmer.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact