shadow : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

shadow
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:

http://mindprod.com/jgloss/shadow.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\shadow.html
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.

IP:[65.110.21.43]
Your face IP:[13.58.200.78]
You are visitor number