1/11
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
arrays
data structure with a group of elements of the same type with an index; memory to hold the whole array in the same spot is allocated.
1-dimensional array
an array with a single line or column of data
what types of variables are array variables?
reference variables - arrays are objects that need to be initialized to use
how to create a new array?
int an_array = new int[6]; //int = data type of the array; stored with default values
int[ ] myIntArray = {1,324,5,6,67}; //initializer list - specific values
default values
numeric - 0 or 0.0; boolean - false; object reference - null
what value do array indexes start at?
0
how to get or set the element value?
System.out.println(array_name[4])
how to get the length of an array?
array_name.length // cannot be used for a null array
are arrays mutable or immutable?
immutable - elements can’t be added or removed without creating a new array
traversing, iterating, walking through an array
sequentially accessing each array element
last valid index of an array
array length - 1
where is the index variable declared when using a while loop?
outside the loop