Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

Constructor injection

I was reading folowing lines and I did not understand clearly.

If a constructor takes two,more parameters of the same type, it may be
difficult to determine what each parameters purpose is.

Constructor injection does not lend itself readily to inheritance. A beans
constructor will have to pass parameters to super() in order to set private
properties in the parent object.

Any ideas, resources,sample code,links, highly appreciated. thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of cmalakar
cmalakar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> Constructor injection does not lend itself readily to inheritance. A beans
>> constructor will have to pass parameters to super() in order to set private
>> properties in the parent object.

If there is any parent class, then while creation, it is very obvious that we should call super() with the required parameter.
On the other hand, setXXXX methods works without need of any super()