Please enable JavaScript.
Coggle requires JavaScript to display documents.
07 Arrays (Declaring, creating and filling an array (int [ ] declares…
07
Arrays
Declaring, creating
and filling an array
int [ ]
declares an array of ints
new int [ n ]
creates an array of n x ints
a [ n ] = x;
sets value of n'th element of array to be x
All elements initially zero / false / null
Iterating over
an array
Using for loop with a [ i ]
Using foreach loop
Single-step
initialisation
Multi-
dimensional
arrays
Declaring and creating
Accessing elements in
multi-dimensional array
Jagged arrays
(arrays of arrays)
General
concepts
Arrays are reference types
Arrays hold items of single type
Size of an array is fixed
Other array
operations
Resizing an array
Sorting an array
Finding index of item in array
Copying an array