1. int[] direct subclass of Object from which it inherit toString method
2.toArray of List returns Object[] so cast as (Integer[])objArray
3.unlike array Object, Integer and String overrides toString() to give meaningful String representation
1.
list2fromarray2 and
listoldstyle are both lists that can hold any type of value,
when used inside System.out.println they should print the contents of the lists.
2.when
listoldstyle is used inside System.out.println ,it prints the list contents.
while
list2fromarray2 made from an array which hold int values,when used inside System.out.println , prints list hashcode.
why such different behavior ?
As far i know list override toString method,so when used inside System.out.println the output should be the list contents
3.The
toArray() is of 2 formats.one that returns an array object and other that returns an array of type passed as it's call argument.In this case
aa .
the code at line 27-29 works fine but code at line 30 requires casting.
The only difference is the
list from which array is being made is different.
code at line 27 uses list2fromarray1(can hold only Integer values)
code at line 30 uses list2fromarray2 that is made from array2(array which holds only int values)
why such a behaviour ?
i didn't get your answer Seetharaman.