educative.io

Educative

Non-Primitive array, objects are stored in heap segment

Hi,

Can someone please expand on what does it mean by in non-primitive array objs are stored in heap segment in the below line?

“In primitive array, values are stored in a contiguous memory location. Whereas, in the non-primitive array, objects are stored in the heap segment.”

Isn’t non-primitive array is still an array of Java objects which are accessed using index? For ex:
Employee[] employees = new Employee[10];
employees[0] = new Employee(…);

Thanks!


Course: Educative: Interactive Courses for Software Developers
Lesson: Educative: Interactive Courses for Software Developers