1.java:
Java itself is not able to implement dynamic arrays, this Java itself does not directly manipulate the pointer is related to "although I think in theory should be the same as C, can be done, but Java does not provide, specific reasons, such as know to add." So the collection of Java, such as the ArrayList collection, is how to implement a "dynamic array". The principle is: the bottom of the ArrayList is an array a "object[] a = new object[]", if you need to change the size of the ArrayList, then discard the original reference to a, and then a new array [ArrayList] B = New object[], length custom], and reference it.
2.c language:
Principle:
(1) Dynamic array-Create, use malloc function: The role of malloc is to dynamically allocate a custom length of contiguous space in memory;
(2) Dynamic array--changing the size of the array, using the Relloc function: The Relloc effect is:
A) Reduce the length of the array: when the memory itself has the remaining space, you can take off its own tail memory as needed "description: The operation of the memory is limited to the memory block allocated by the array";
b) Increase the length of the array: when there is extra space at the end of the memory where the array is located, add the memory directly to the back of the original memory block, and if the original memory is out of space, Relloc re-allocates a new memory space and copies the contents of the original memory to the new memory block.
"8.0" questions about dynamic arrays of Java and C