Thursday, June 01, 2006

SuperClass variable

If you define a variable in your subclass with the same name as a variable in your superclass, the superclass variable is hidden. This can lead to hard-to-find errors, so be careful about doing this. The JVM always uses the variable that is the “most local” to the object. If a variable x is defined in both the superclass and the subclass, a subclass instance “sees” only its own variable.

0 Comments:

Post a Comment

<< Home