In the following example pseudocode:
public class MyPanel extends JPanel {
public void reset() {
this.clear();
clear();
}
public void clear() { System.out.println("FAIL"); }
};
public class MySpecialPanel extends MyPanel {
public void clear() { System.out.println("Hello, world"); }
};
When calling (new MySpecialPanel()).reset() shouldn’t both this.clear() and clear() resolve in the same scope? Is there any difference between this.clear() and clear()?
In the code above, that calls the same method twice. There is no difference between
clear()andthis.clear().You can explicitly call the superclasses method with
super.clear().