CCA Guide
Arrays

Arrays

Curated by Last modified: 1 min read

View Markdown

Define an array of size n

int[] myArray = new int[n];

An array has a fixed length. Its indices run from 0 to n - 1; newly created int elements are initialized to 0.

Define an array with elements

int[] myArray = new int[] {1, 2, 3};

Related: Variables · Loops

Linked to this page