If you declare a generic array that does not have a space length specified, such as arraylist<integer> in = new
Arraylist<> (), the system will automatically allocate 10 capacity space for in, that is, [null,null,null,null,null,null,null,null,null,null], if this is the in assignment, such as:
for (int i=1;i<=5;i++) {
In.add (i);
}
In this case, the content of in is actually [1,2,3,4,5,null,null,null,null,null], which is five null values, but 5 is obtained with the In.size () method, excluding the subsequent null, when implementing the ToString () method of reflection, The following null values may be printed, such as:
Java.util.arraylist[elementdata=class java.lang.object[]{java.lang.integer[value=1][][], Java.lang.integer[value=4][][],
Java.lang.integer[value=9][][],java.lang.integer[value=16][][],java.lang.integer[value=25][][],null, null,null,null,null},
Size=5][modcount=5][][]
Even if the size of the ArrayList is specified initially, such as arraylist<integer> in = new arraylist<> (4), the size of the ArrayList itself will grow dynamically when the array element is dynamically increased to a certain amount. The growth value is 4->7->11->17 ..., instead of increasing the capacity one by one, follow the rules ((Old capacity * 3)/2) + 1.
In addition, an array is an object in Java, which means it can be referenced as such:
int New int [publicstatic Object XXX (Object a) { ...}
Generic array list and reflection