public class TestArray { public static void main (String[] argv) { // Declaration: A is an array of int's int[] A; // The new operator instantiates an array with a given size. A = new int[10]; // Individual items are referred to using square brackets. // Indexing starts from 0. for (int i=0; i<10; i++) A[i] = i; // This will compile but create a runtime exception. A[10] = 5; // A.length is a field indicating the length. System.out.println ("Number of elements of array A: " + A.length + "\nContents:"); // Size can be determined dynamically. int size = 10; double[] B = new double[size]; // Arrays can be initialized String[] C = {"Michael", "Scottie", "Toni", "Dennis", "Luc"}; } }