Aryan PrajapatKnowledge Contributor
Contiguous memory locations are usually used for storing actual values in an array but not in ArrayList. Explain.
Contiguous memory locations are usually used for storing actual values in an array but not in ArrayList. Explain.
Primitive data types like int, float, and others are typically present in an array. In such circumstances, the array immediately saves these elements at contiguous memory regions. While an ArrayList does not contain primitive data types. Instead of the actual object, an ArrayList includes the references to the objects’ many locations in memory. The objects are not kept in consecutive memory regions because of this.