View RSS Feed


Add to array

  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, ...
  2. Declaring a Variable to Refer to an Array

    by , 03-04-2012 at 11:02 AM
    Array is declared in the above program along with this line of code.
    Java Code:
    // declares an array of integers
    int[] anArray;
    Array declaration also consists of 2 components, just like other declarations for other types of variables. They are
    • Array’s name
    • Array’s type

    Array’s type is written as type[].

    An array’s name could be anything that you may want provided it follows the conventions. Just like other type variables, array ...
    Tags: refer array Add / Edit Tags
  3. Java Array

    by , 03-04-2012 at 11:00 AM
    Array is that container object which consists of fixed value numbers of one single type. When array is created, establishment of the length of an array takes place. Length is fixed after creation of an array. In Hello world application’s main method, example of array has already been given. Here detailed array section will be given.

    Name:  1.JPG
Views: 515
Size:  10.5 KB
    An array of ten elements

    Every item present in array is known as an element. Numerical index is used ...
    Tags: java array Add / Edit Tags