How arrays are represented in the jvm?

How arrays are represented in the jvm as it finds the element at index of the array, for example somewhere in the middle. She, it turns out, still goes through all array elements and finds, or some other mechanism? If so, what difference jvm - array or a linked list, why is the operation of nding an element in the middle of the array faster ?
July 12th 19 at 17:26
1 answer
July 12th 19 at 17:28
Arrays on the JVM are quite real, that is, occupy contiguous space in memory as in C/C++, that is implemented NOT on the lists.
The operation of the access element of the array has complexity O(1), and the JIT optimizes it to a single machine instruction (on x86), that is, as well as access a local variable on the stack or field of a class.
A separate element of the array - not the same as a separate variable or field of a class, the memory that it occupies will not be freed until will not be released until the whole array.
What can you advice to read/see how that works in the jvm? - iliana.Hickle commented on July 12th 19 at 17:31
: https://docs.oracle.com/javase/specs/jvms/se8/html... - peggi commented on July 12th 19 at 17:34

Find more questions by tags JavaJVM