Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Java

Idiom #303 Array with non-default lower bound

Declare an array a of integers with six elements, where the first index is 42 and consecutive elements have the indices 43, 44, 45, 46, 47.

int a[] = new int[42 + 6];
for (int i = 42, n = 42 + 6; i < n; ++i) {

}

In Java, all arrays start at 0.
A : array (42 .. 47) of Integer;

A'First is 42, A'Last is 47, A'Length is 6.

New implementation...
< >
tkoenig