Logo

Programming-Idioms

History of Idiom 7 > diff from v139 to v140

Edit summary for version 140 by reilas:
New Java implementation by user [reilas]

Version 139

2022-10-07, 19:20:04

Version 140

2023-01-25, 12:59:07

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

Variables
i,x,items
Variables
i,x,items
Extra Keywords
indices traverse traversal
Extra Keywords
indices traverse traversal
Code
int i = 0;
for(String x : items) {
	System.out.printf("%d %s%n", i, x);
	i++;
}