java arrays Flashcards
(16 cards)
a container object that holds a fixed number of values
of a single type.
array
The length of an array is established when the array is
____.
created
true or false: an array can store multiple values of different types.
false. it can store multiple values of the same type
true or false: array uses ZERO-based indexing( first elements at index 1)
false. first elements start at index 0
true or false: arrays have a fixed size, meaning it cannot grow or shrink dynamically.
true
elements in array are stored in _____
contiguous memory locations
Use ____ to access elements (arr[index]).
indexing
for-each format
for (int y : number){
System.out.println(number[y]); //print all element in the array
}
The ____ class is a resizable array, which can be found in
the java.util package.
ArrayList
difference between a built-in array and an ArrayList in Java
the size of an array cannot be modified, while elements in ArrayList can be.
to add elements
to the list, use the ____ method:
add()
To access an element in the ArrayList, use the ___ method and refer to the index number:
get()
To modify an element, use the ___ method and refer to the index number:
set()
– to remove an item, use the ____ method and refer to the index number
remove() ,
To remove all the elements in the ArrayList, use the
____ method:
clear()
to find out how many elements an ArrayList have, use the ____ method
size()