Skip to content

Instantly share code, notes, and snippets.

@skrekhere
Created November 24, 2018 07:35
Show Gist options
  • Save skrekhere/6e95a910efada3ef538765a14907d0a1 to your computer and use it in GitHub Desktop.
Save skrekhere/6e95a910efada3ef538765a14907d0a1 to your computer and use it in GitHub Desktop.
//initializing parent class
class A{
int x;//variable as example
A(int _x){//constructor
x = _x;//init
}
}
//extending class
class Derived extends A{
int y;//variable as example
Derived(int _x, int _y){//constructor
super(_x);//super calls the parent constructor to avoid any errors
y = _y;//init
}
}
void main(){
Derived d = new Derived(0,0);//variable things
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment