SE450: Overriding: Hiding [9/35] Previous pageContentsNext page

A declaration is hidden if another declaration of the same name occurs in the scope of the outer declaration.

public class A {
    int x;
    static void z() { ... }
}
public class B extends A {
    float x;                // old x still in scope, use super.x
    static int z() { ... }  // old z still in scope, use A.z()
    byte x (char x) {       // oh dear...
      char c = x;
      float f = this.x;
      int i = super.x;
      byte b = this.x();
    }
}

You should avoid hiding

http://developer.java.sun.com/developer/TechTips/2000/tt1010.html#tip2

Previous pageContentsNext page