Unit 3 - Arrays Flashcards
data structure
a general term that is used to describe a collection of related data items
array
a numbered list that stores related data items (same type)
ArrayList
a resizable array
dynamic resizing
relateds to ArrayLists
the ArrayList grows as items are added and shrinks when items are removed
array is fixed in size
element
an item in an array
index
the location/position of an item in an array
length
instance variable called field
the number of elements in an array
initializer
can set the elements of the array, a common-separated list of expressions enclosed in braces
bounds checking
off-by-one error
making sure array indices are greater than or equal to 0 and less than the length of the array; out of bounds b/c index is too high or too low
singular - index, plural - indices
enhanced for statement
a.k.a for-each loop
a special loop that iterates through the elements of an array without using a counter, it avoids the possibility of “stepping outside” of the array
ex. for (parameter : arrayName)
statement
pass-by-value
call-by-value
a copy of an argument’s value is passed to the called method; the method uses the copy and the original value is not changed
pass-by-reference
call-by-reference
a reference of the argument’s value is passed to the method; the method can access the actual parameter and modify its value
two-diemensional array
a.k.a matrix
used to represent table of values consisting of information arranged in rows and columns
command-line arguments
is an argument passed at the time of running the program
Array class
a class from the java utility package that provides static methods for common array manipulations