If i have an array say -
int[] a = new int[10];
does the Java GC when doing its collection see that as 10 objects or a single object?
Update:
so according to the given answers, looking at it from a GC perspective isnt it more efficient that instead of
List l;
for(i =0;i<1000;i++)
l.add(new MyObj(343,"asdfasfd"));
we should do -
int[] a; String[] b;
for(i =0;i<1000;i++) {
a[i]=343;
b[i] = "asfasfsafsaf";
}
because in the first case we end up creating 1000 extra objects while in the 2nd case we do not.