Regarding the heap memory

I was not able to understand how come the memory was increased from 4 to 8.
And can we use list[INDEX] to access the element in the array instead of using get function

hey @mishikasrvastava
Add element at the end if the array size is not enough then extend the size of the array and add an element at the end of the original array as well as given index. Doing all that copying takes O(n) time, where n is the number of elements in our array. That’s an expensive cost for an append. In a fixed-length array, appends only take O(1) time.
But appends take O(n) time only when we insert into a full array. And that is pretty rare, especially if we double the size of the array every time we run out of space. So in most cases appending is still O(1) time, and sometimes it’s O(n) time.

I am yet not able to understand

when a ArrayList is declared and initialized using default constructor, memory space for 10 elements will be created. now, when i add 11 th element, what happens is

ArrayList create a new object with the new size ( copy all element of old ArrayList)
if you are not able to underStand don’t worry ,When you will learn HashMap you will see how come the memory was increased from 4 to 8( internally ).