View RSS Feed

Java Array

Java arrays.

  1. Creating, Initializing, and Accessing an Array

    by , 03-04-2012 at 11:05 AM
    One can create an array by the help of the new operator. In ArrayDemo program, next statement allocates the array along with quite enough memory. This is done for 10 integer elements so that to assign array to anArray variable.

    Java Code:
    // create an array of integers
    anArray = new int[10];
    In case if the given statement is missing, an error like this would be printed by compiler and also the compilation would fail.

    To array’s each element, ...