Logo

Programming-Idioms

History of Idiom 7 > diff from v84 to v85

Edit summary for version 85 by programming-idioms.org:
[Java] Emphasize in comments

Version 84

2020-04-24, 09:48:47

Version 85

2020-04-24, 09:49:08

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Extra Keywords
traverse traversal
Extra Keywords
traverse traversal
Code
for (int i = 0; i < items.length; i++) {
    T x = items[i];
    System.out.printf("Item %d = %s%n", i, x);
}
Code
for (int i = 0; i < items.length; i++) {
    T x = items[i];
    System.out.printf("Item %d = %s%n", i, x);
}
Comments bubble
Solution if the list is an array.
Comments bubble
items is an array.