The most common way to walk through every element in an array is a standard for loop:
String[] names = {"Alice", "Bob", "Carol"};
for (int i = 0; i < names.length; i++) {
System.out.println(names[i]);
}
The variable i starts at and increments by each iteration. The condition i < names.length stops the loop before it goes out of bounds.
Because you control the index, you can also loop backward, skip elements, or access neighboring elements like arr[i - 1]. This flexibility is why the standard for loop remains the default choice when you need the index during iteration.