AP® Computer Science A glossary
Traversal
Also called: traversing
Course: AP® Computer Science A Shows up in: Unit 4: Data Collections
Using repetition (or recursion) to access all elements of an array or ArrayList, or an ordered sequence of them.
Appears in the course and exam description (CED): 4.4.A.14.4.A.24.9.A.14.9.A.2
A traversal can go forward, backward, every other element or over part of the collection. Indexed loops can change elements; removing from an ArrayList during a traversal needs care so no element is skipped.
int[] steps = {3, 5, 8};
for (int i = steps.length - 1; i >= 0; i--)
{
System.out.print(steps[i] + " ");
}
System.out.println();
Output:
8 5 3 Learn it properly, with a checkpoint 4.4 Array Traversals