Briefly explain what an array is. As part of your answer make use of a labelled example to show the declaration and components of an array Note: You will receive 4 marks for your explanation and 6 marks for your labelled example.
An array is a collection of elements stored in contiguous memory location. Each element has an index, which indicates the position they occupy in the array. The array can be seen as container that holds a collection of data. Elements in array can be accessed sequentially and be manipulated.
In Java programming language, array can be declared as
datatype [array_size] array_name = new datatype([array_size]);
The datatype can be double, float, and int.
Comments
Leave a comment