How come when swiffer(aa) is run, a 4 is produced instead of a 1?
Note that you are creating an array of A, but not initializing the individual elements of the array. Therefore, it is treated as an Object and 4 is displayed when
is executed.
Similarly, you are only creating one array object ba[], but not initializing the individual elements. Therefore,
is executed and 3 is displayed.
Finally, as you mentioned, sifter(7) gets boxed to an Integer and widened to an Object to display 4.
Also, I would like to add that in order for this example to behave the way you had expected, you would have to do something like
[ December 10, 2008: Message edited by: Prateek Parekh ]