Arrays are derived data structures that store multiple primitive data types. Note that, unlike Lists, all objects in an array must be the same type.

Properties

  • A data structure with a set length
  • Items are accessed via their index, which is a number that stores their location
  • They are static (a fixed size) (not to be confused with Static in OOP ). Specifically, their length cannot be changed once initialised.
  • Items are added to arrays by overwriting previous value via index

ADT Signature

name: Array
import: element,int,bool
ops:
	newArray: → Array
	append: Array x element x int → Array
	get: Array x int  → element
	isEmpty/isFull: Array → bool
	length: Array → int

Implementation

Most Programming Languages store arrays as references to memory locations. That is, if we create an array, simply trying to assign it to something else will copy the reference, not the value:

In Java

#todo

{} is the syntax to for new int[] {3,3,5,5} creates a new unique array.