Skip to content

Instantly share code, notes, and snippets.

@sampottinger
Created June 16, 2012 21:31
Show Gist options
  • Save sampottinger/2942546 to your computer and use it in GitHub Desktop.
Save sampottinger/2942546 to your computer and use it in GitHub Desktop.
Java public method inheritance
public class ClassA {
public void test()
{
System.out.println("Testing...");
sayHi();
}
public void sayHi()
{
System.out.println("hiA");
}
}
public class ClassB extends ClassA {
public void sayHi()
{
System.out.println("hiB");
}
}
public class Runner {
public static void main(String[] args) {
ClassB b = new ClassB();
b.test();
}
}
Testing...
hiB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment