Does an array or an ArrayList require contiguous memory allocation in Java? I understand that this is a fundamental question but I am finding conflicting information on the topic.
My intuition is that an array does not require contiguous memory allocation (since an array is just an address in memory so there is not much restriction on how memory is allocated after that address). To my understanding an ArrayList adds an extra constraint requiring elements to be arranged contiguously. Is that accurate?
I'm sorry if this has been asked before but I have not been able to find a direct answer. This is the closest I could find, but it adds a little more confusion saying that contiguous memory allocation with ArrayLists is JVM-specific, where I would think of contiguous allocation as the defining feature of ArrayLists.