All Flashcards
What are the differences between using a for loop and a while loop for array traversal?
For loop: More concise, easier to read iteration count. While loop: More flexible, requires manual index management.
What are the steps to traverse an array forwards using a for loop?
Initialize index to 0, check if index is less than array length, access element at index, increment index.
What are the steps to traverse an array in reverse using a for loop?
Initialize index to array.length - 1, check if index is greater than or equal to 0, access element at index, decrement index.
What is array traversal?
Accessing every value in an array.
What is forward traversal?
Accessing array elements from the beginning to the end.
What is reverse traversal?
Accessing array elements from the end to the beginning.
What is a limited traversal?
Accessing only a portion of elements in the array.
What is ArrayIndexOutOfBoundsException?
An error when trying to access an index that does not exist.