Skip to content

Instantly share code, notes, and snippets.

@asicfr
Created June 1, 2016 07:59
Show Gist options
  • Save asicfr/bd1cf175cbdfa465d953d31382683c41 to your computer and use it in GitHub Desktop.
Save asicfr/bd1cf175cbdfa465d953d31382683c41 to your computer and use it in GitHub Desktop.
The distinction between hiding and overriding method
class A {
public static void display() {
System.out.println("Inside static method of superclass");
}
}
class B extends A {
public void show() {
display();
}
public static void display() {
System.out.println("Inside static method of this class");
}
}
public class Test {
public static void main(String[] args) {
B b = new B();
b.display();
A a = new B();
a.display();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment