Skip to content

Instantly share code, notes, and snippets.

@tomty89
Last active November 30, 2021 18:38
Show Gist options
  • Save tomty89/6cf965ac9737a66f3b947349c63649a6 to your computer and use it in GitHub Desktop.
Save tomty89/6cf965ac9737a66f3b947349c63649a6 to your computer and use it in GitHub Desktop.
class A {
private int a;
// private int b;
int b;
// private void aa() {
// a++;
// }
void aa() {
a++;
}
}
class B extends A {
void bb() {
b++;
}
}
public class Inherit {
public static void main(String[] args) {
B b = new B();
b.aa();
A a = b;
a.aa();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment