Traversing an array means going through each element in the array, typically to perform some operation such as printing, calculating, or modifying values. Understanding how to traverse arrays is essential because it lays the foundation for developing algorithms, which we will explore further in 6.4.
In this section, we will use for loops for traversal. For loops are ideal for arrays because they let you systematically go through each index, starting from the first and ending at the last. This is useful because the number of iterations corresponds to the size of the array.
The field .length provides the total number of elements in an array. This will be very useful for traversing arrays when we loop through arrays. Since it's a field, you don’t need parentheses, unlike when you use .length() with a string.