Memory representation of an array?

We can view memory itself as a giant array. On moden computers, memory is implemented in hardware as a sequence of indexed memory locations that each can be quickly accessed with an appropriate index.

Suppose that a computers memory is organized as 1000 values, with addresses from 000 to 999. Suppose that an array of eight elements is stored in memory locations 523 through 530. In such a situation, Java would store the memory addresses of the first array value somewhere else in memory, along with array length. We refer to the adress as a pointer and think of it as pointing to a location.

Interesting. I think classically (in C) multi dimensional arrays could also be interpreted as multi dimensional pointers. I'm not entirely sure how Java Virtual machine would do it, but I would expect the outermost dimension would be as you said, a continuous region of memory. Only its values, instead of being a data type value, would in turn be a pointer, to the contents of the array at that location, which in this case. and while the contents of the second dimensional array, say the first index on the outer dimension, e.g. Array[0][],, would itself also be a continous organisation of memory addresses of the length of its array, there would likely be no guarantee that this would sequentially follow the continous memory address of the outer array.

that is, we probably could not just find the first element of Array[0][0] at memory address 531 (the address after the single outer array in your example(

I hope this isn't considered necroing, if it is, I appologise in advance.
The deal with 2d arrays, is that they are acctually arrays of arrays. If you look at how a 2d array is initialized, this becomes quite clear. You define an array by specifiying the type that it holds (let's say int) and add brackets to declare it's an array, not a single variable. So if you write int[][] arr; you can look at it as an array, that holds int[] elements, rather than a 2d array of ints.

So let's say we have an array of Objects:

Java Code:

Object[] arr = new Object[10];

So what we do then, is fill the Object array with Object arrays:

Java Code:

for(int i = 0; i < 10; i++)
arr[i] = new Object[10];

This means, that the array arr stores the references to the newly created arrays. So, in essence, the first array would occupy the memory spaces from 300 to 309, and each of those spaces would point to another memory address, where the acctual array is held.