Computer Applications
Write a note on how single-dimension arrays are represented in memory.
Java Arrays
3 Likes
Answer
Single-dimensional arrays are lists of information of the same type and their elements are stored in contiguous memory locations in their index order.
Internally, arrays are stored as a special object containing :
- A group of contiguous memory locations that all have the same name and same datatype.
- A reference that stores the beginning address of the array elements.
- A separate instance variable containing the number of elements in the array.
For example, an array grade of type char with 8 elements declared as
char grade[ ] = new char[8];
will have the element grade[0] at the first allocated memory location, grade[1] at the next contiguous memory location, grade[2] at the next, and so forth. Since grade is a char type array, each element size is 2 bytes and it will be represented in memory as shown in the figure given below:

Answered By
1 Like
Related Questions
What is an array ? What is the need for arrays ?
What are different types of arrays? Give examples of each array type.
How does the amount of storage (in bytes) depend upon type and size of an array? Explain with the help of an example.
What do you understand by two-dimensional arrays ? State some situations that can be easily represented by two-dimensional arrays.