0 votes
in JAVA by
Contiguous memory locations are usually used for storing actual values in an array but not in ArrayList. Explain.

1 Answer

0 votes
by
In the case of ArrayList, data storing in the form of primitive data types (like int, float etc.) is not possible. The data members/objects present in the ArrayList have references to the objects which are located at various sites in the memory. Thus, storing of actual objects or non-primitive data types (like Integer, Double etc.) takes place in various memory locations.

However, the same does not apply to the arrays. Object or primitive type values can be stored in arrays in contiguous memory locations, hence its every element does not require any reference to the next element.

Related questions

0 votes
0 votes
asked Oct 4, 2022 in Redis by sharadyadav1986
0 votes
asked Jan 27, 2020 in JAVA by rahuljain1
...