- Analyze the output of this code.
- The sum is 30 since the
type
isint
andindex
is 1 and 0 respectively. - Since
index
is 1 for 1st constructor, the value ofa
is20
. - Since
index
is 0 for 2nd constructor, the value ofb
is10
.
`
<bean class="com.constructor.injection.beans.AddNumber" id="addNumber">
<constructor-arg type="int" index="1" value="10" />
<constructor-arg type="int" index="0" value="20" />
</bean>
`
- Spring calls
public AddNumber(int a, int b)
constructor and hence the output.