InterviewSolution
Saved Bookmarks
| 1. |
Contiguous memory locations are usually used for storing actual values in an array but not in ArrayList. Explain. |
|
Answer» 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 EVERY element does not require any reference to the next element. |
|