Hi Ritu,
You are getting an output or 112 because of this code
As you know 2D arrays in
java are just Arrays containing other arrays as elements.
here in
int[] ia = (int[])obj[i];
ia would contain an
array of elements {1,2} ie. the first array in the first iteration,
array of elements {0,1,2} in second iteration and
array of {-1,0,2} in thrid iteration.
when you print elemnts using
System.out.print(ia[i]); // 5
so in the first iteration ia contains {1,2} and you print the i'th element of ia that is 0th element which prints 1
In the second iteration ia contains {0,1,2} and you print the i'th element of ia that is 1st element which prints 1
In the Third iteration ia contains {-1,0,2} and you print the i'th element of ia that is 2nd element which prints 2
hence the output 112;
here you are not assigning a multidimensional array to ia, infact you are assigning a single dim. array ie. array contained by the multidimensional array obj as its elements.
Note: obj is a multidim array not the arrays contained by obj.
Hope this make you clear.
Sandy
[ September 13, 2005: Message edited by: Sandeep Chhabra ]