Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 433 Bytes

File metadata and controls

16 lines (12 loc) · 433 Bytes

Iterate over an Array

In the same way you can use a for loop to go through each character of a String, you can use it to go through each element in an array.

~void main() {
int[] numbers = { 4, 1, 6, 9 };

for (int index = 0; index < numbers.length; index++) {
    IO.println(numbers[index]);
}
~}

The only difference from Strings is that instead of .length() and .charAt(...), you use .length and [].