Learn to Program with ZedLX

Free Online Programming Course for Beginners

Arrays [1/11]


Arrays

An array is a variable that can hold multiple values of the same type.

In the first statement, the array a is initialized to contain four elements. The variable a is of type int[], which represents an array of integers.

The values contained in an array are called elements of the array. Each element of an array acts just as an ordinary variable.

The example program shows how to create an array, access its elements, and assign new values to them. Each element can be accessed and manipulated individually using its index in square brackets.

Loading...