Indexed arrays are arrays that store a set of values in a sequence of positions which are specified by an index, which is an integer number. PBL uses zero-based arrays, meaning that the index of the first position of the array is zero rather than one. Zero-based arrays are used in Java and Visual Basic as well.
ages as Int[]
The code above declares an indexed array named ages, which is of type Int.
ages as Int[] ages = [23, 42, 29]
The code above initializes the empty array ages, with the integer values 23, 42, and 29.
ages as Int[] codes = [505, 607, 404, 405, 307, 806] codes[6] = 306If you skip an index value, an Index out of bounds error is thrown.
ages as Int[] ages = [23, 42, 29] display ages[0]
If you pass an index which is higher than the last available index (in the example, the last index is 2), an Array index out of bounds error results.
codes as Int[] codes = [505, 607, 404, 405, 307, 806] I = 2 display codes[1 + 2] display codes[i] display codes[i * 2]
Names as String[] names = ["Bill", "Ed", "Alfred"] names[1] = "Edward" display names