Logo

Programming-Idioms

History of Idiom 7 > diff from v124 to v125

Edit summary for version 125 by suren:
[Java] check

Version 124

2022-01-14, 10:59:09

Version 125

2022-02-13, 18:11:36

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
for (int i = 0; i < items.length; i++) {
    T x = items[i];
    System.out.printf("Item %d = %s%n", i, x);
}
Code
class test
{
	public static void main (strimg[] args)
	{
		int arr1[] = {1,2,3};
		int arr2[] = {1,2,3};
		if (arrays.equals(arr1,arr2))
		system.out.println("same");
		else
		system.out.println("same");
	}
}
Comments bubble
items is an array.
Comments bubble
items is an array.