Created
June 16, 2012 21:31
-
-
Save sampottinger/2942546 to your computer and use it in GitHub Desktop.
Java public method inheritance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ClassA { | |
public void test() | |
{ | |
System.out.println("Testing..."); | |
sayHi(); | |
} | |
public void sayHi() | |
{ | |
System.out.println("hiA"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ClassB extends ClassA { | |
public void sayHi() | |
{ | |
System.out.println("hiB"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Runner { | |
public static void main(String[] args) { | |
ClassB b = new ClassB(); | |
b.test(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Testing... | |
hiB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment