shadow : Java Glossary


When a subclass has a variable by the same name as one of its superclasses we call that shadowing. Be warned. The rules for inheritance for variables are quite different than for methods. Be careful. The rules for figuring out exactly which version of a variable get invoked are baroque.

Don’t shadow. You will just end up confusing yourself and the people who read your code. It is silly as calling two of your sons Jim. The only reason shadowing is permitted at all is to allow you to write a subclass without access to the source code for the superclass, to forgive you accidentally reusing a field name.

Learning More

This page is posted
on the web at:

Optional Replicator mirror
on local hard disk J:

Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

Your face IP:[]
You are visitor number