0
Super() can called parametric as well as non-parametric constructor.
I understand how super() called a non-parametric constructor. But i fail to understand how super(arg1) called a parametric constructor. Can somebody explain and give me an example code. Thank you
3 odpowiedzi
0
Here is an example:
https://code.sololearn.com/cYNMZPFp35Ax/?ref=app
Example has two constructors.
public Example() -> super()
public Example(int i) -> super(an integer value)
0
if you would have an constructor like this:
public Example(int i, String s){
}
-> enter an integer value than a String
-> it works like calling methods
In the child class:
super(9, "hi");
0
You can also have look into my code about constructor chaining:
https://code.sololearn.com/cJI0TrD1mipb/?ref=app