1/43
A collection of vocabulary terms and definitions related to ArrayList and Java programming concepts relevant to the lecture notes.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
ArrayList
A resizable array implementation of the List interface in Java.
IndexOutOfBoundsException
An exception thrown to indicate that an index is out of range.
add(index, obj)
Inserts an element at the specified index in the ArrayList and shifts subsequent elements.
list.size()
Returns the number of elements in the ArrayList.
set(int index, E obj)
Replaces the element at a specified index with a new object.
size
The number of elements currently stored in the ArrayList.
remove
Removes an element from the ArrayList at the specified index.
for (String s : words) {…}
A for-each loop used to iterate over elements in a collection.
ArrayList
A generic array list that holds Integer objects.
x.add(1, 99);
Adds the value 99 at index 1, shifting existing elements to the right.
s.get(1)
Retrieves the element at index 1 from the ArrayList.
throws
Indicates that a method may throw an exception during execution.
a.set(0, a.get(1));
Sets the first element to the value of the second element.
ArrayList
Creates a new ArrayList that will hold String objects.
compiles
Means that the code is verified without any syntax errors during the compilation phase.
System.out.println(a);
Prints the content of the ArrayList to the console.
infinite loop
A loop that continues indefinitely without terminating.
shifts
Moves elements to accommodate new additions or removals in the ArrayList.
equals
A method used to compare two objects for equality.
add(0, "bye")
Inserts the string 'bye' at index 0 of the ArrayList.
a.size() - 1
Calculates the index of the last element in the ArrayList.
A. [0, 1, 2, 99]
One of the options printed from a console statement concerning an ArrayList.
B. [4, 4, 6]
The output resulting from setting an ArrayList's element.
C. Both A and B
Indicates that two conditions are valid regarding loops that print ArrayLists.
destroys
To remove all elements from a collection.
public static void swapEnds (ArrayList
Prototype for a method to swap the first and last elements of an ArrayList.
size is fixed
Indicates an ArrayList cannot resize after its construction; this is incorrect.
remove(i)
Removes the element at the specified index i from the ArrayList.
compiling error
Error that occurs during the compilation of code, indicating issues with the syntax.
A.add(1)
An attempt to add an element at a specific index which may fail if index is out of bounds.
for (int i = 0; i < d.size(); i++)
A traditional for loop to access a list's elements.
B.add("x")
Adding an element to the ArrayList, which can alter the list's size.
get(i)
Retrieves the element at the specified index i in an ArrayList.
G. [1, 3]
The resulting output from removing alternate elements in an even-numbered list.
Comparator
Comparison function used to order elements in a collection.
dynamic resizing
The ability of an ArrayList to increase or decrease its capacity automatically.
d.get(i) + " "
The method used to print each element of the ArrayList with a space.
swap
The action of swapping positions of elements.
O. IndexOutOfBoundsException
Error raised when an attempt is made to access an invalid index.
method prototype
Declaration of a method that defines its parameters and return type.
for (Strings : a) {…}
A for-each loop iterating through elements of the ArrayList.
removes
Discards elements from a collection or removes them.
C. [hi, yo, bye]
Expected output after adding and rearranging elements in the ArrayList.
ADD(a.size(), first);
A faulty attempt to add an element to the ArrayList, should not specify an index equal to size.