Here We have declared two beans with corresponding ids.
1.Class Country with id as “CountryBean”
2.Class Capital with id as “CapitalBean”
constructor-arg tag is used for providing argument to bean’ s constructor.type is for declaring data types and index defines position in constructor’s argument.
In above xml,Two arguments are passed.
1. India as string
2.CapitalBean ‘s reference
Property’s value tagis for assigning value to corresponding attribute. so In above xml file,we have assigned capitalName attribute of Capital class with value as Delhi

1

2

3

<propertyname="Name Of Attribute"value="Value Of attribute to be assigned"/>

Property’s ref tagis used for assigning reference to the corresponding attribute. so In above xml file, we have assigned reference of Capital class to capital attribute of Country class.

1

2

3

<propertyname="Name Of Attribute"value="id of referencing bean"/>

4.ConstructorDIMain.java

This class contains main function.Create ConstructorDIMain.java under package org.arpit.java2blog.