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

28th Jul 2019, 6:23 PM
stephen haokip
stephen haokip - avatar
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)
28th Jul 2019, 7:18 PM
Denise Roßberg
Denise Roßberg - avatar
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");
28th Jul 2019, 7:23 PM
Denise Roßberg
Denise Roßberg - avatar
0
You can also have look into my code about constructor chaining: https://code.sololearn.com/cJI0TrD1mipb/?ref=app
28th Jul 2019, 7:24 PM
Denise Roßberg
Denise Roßberg - avatar