/******************************************************************************
 * Example of arrays
 ******************************************************************************/
public class array1
{
    public static void main (String[] args) 
    {

    //------------ declare, then allocate space ---------------------------

        int[ ] numArray;                    //declare an array

        numArray = new int[5];              //allocate space for 5 int
    
        numArray[0] = 1;                    //store 1 in first element    
        numArray[1] = 3;     
        numArray[2] = 5;  
        numArray[3] = 7;   
        numArray[4] = 9;

        int first = numArray[0];                //access first element
        int last  = numArray[4];  
        int size  = numArray.length;            //how big is array?

        System.out.println("First element is: " + first);
        System.out.println("Last  element is: " + last);
        System.out.println("Size of array is: " + size);

        System.out.print("Loop: \t\t");            

        for (int i=0; i < numArray.length; i++)     //loop as long as the array
        {
            System.out.print(numArray[i] + " ");    //print element value
        }    
        System.out.println();                       //print empty line


    //------------ declare and allocate space ---------------------------

        float[ ] num2Array = new float[5];          //declare and allocate space
    
        num2Array[0] = 1.90f;                       //store 1 in first element    
        num2Array[1] = 2.89f;     
        num2Array[2] = 3.14f;  
        num2Array[3] = 4.66f;   
        num2Array[4] = 5.31f;

        System.out.print("Loop............: ");            

        for (int i=0; i < num2Array.length; i++)    //loop as long as the array
        {
            System.out.print(num2Array[i] + " ");   //print element value
        }
        System.out.println();                       //print empty line

        System.out.print("Loop another way: ");            

        for (float num : num2Array)                 //loop another way
        {
            System.out.print(num + " ");            //print element value
        }
        System.out.println();                       //print empty line


    //------------ declare, allocate and initialize -----------------------

        char[ ] vowels = {'A','E','I','O','U'};     //declare, allocate and init
    
        System.out.print("Loop another way: ");            

        for (char vowel : vowels)                   //loop as long as the array
        {
            System.out.print(vowel + " ");          //print element value
        }
        System.out.println();                       //print empty line
    }
}