According to basics
-->int[] is array of primitive
-->and Integer[] is object array
But I am not able to understand the behavior when you convert both into List. Please refer the example to understand the question
scenerio 1:
int [] a1={2,10,55,60};
/** To covert it into List
**/
List list = (Arrays.asList(a1));
System.out.println("size :"+list.size());
Iterator it =list.iterator();
while (it.hasNext()){
System.out.println(it.next());
}
the out put for the above code is size :1 [I@f74f6ef(Address )
scenerio 2:
Integer [] a1={2,10,55,60};
/** To covert it into List
**/
List list = (Arrays.asList(a1));
System.out.println("size :"+list.size());
Iterator it =list.iterator();
while (it.hasNext()){
System.out.println(it.next());
}
the out put for the above code is size :4
2
10
55
60
Now one reason could be that the a1(int) might be holding all the elements of the array with address as Address+4(int) for consecutive elements. and whereas a1 (Integer) would be holding the address of each and every element.
so might be reason that the size in case of int is 1 and in Integer its 4.
I am not sure with the above statement. can some one please help me to understand the situation??