/*
 * @topic T01105 Array Reference Demo I
 * @brief Array initialization and enhanced (foreach) loop examples
*/
package pckg;

/* This demo contains a reference for:
 *
 * (1) Declaring and instatiating an array of float elements
 *
 * (2) Declaring, instantiating and initializing an array of float elements
 *
 * (3) A variable (scores) that is declared, instantiated, and intiialized, and 
 *     then displayed in an enhanced for loop.
 *     Note how newscores is declared, instatiated, and assigned the same address
 *     as scores.
 * 
 *     scores is then instantiated again and is now referencing a 5 element array
 *     and scores no longer references the 3 element array.
 * 
 *     All of the elements in scores default to a value of zero, and this is
 *     verified with a display of the 5 elements in scores, using a loop.
 * 
 *     Note at the end, that the newscores array is displayed and it still
 *     contains the address of the original 3 element array that was originally 
 *     instantiated as scores.
 */

public class ArrayReferences
{
    public static void main(String[] args)
    {
        
     float [ ] floatarray = new float[10];
     
     float [ ] myarray = { 2.2F, 3.3F, 4.4F, 5.5F };    
     
     //***********************************************
     int [ ]scores = { 3, 5, 7 };
     
     for( int x : scores)
     {
             System.out.println(x);
     }
     
     //***********************************************     
     int [ ] newscores = scores;
     
     scores = new int[5]; 
     
     for( int x : scores)
     {
             System.out.println(x);
     }
     
     for( int x : newscores)
     {
             System.out.println(x);
     }
     
     
        
    }// end of main    

}// end of class

/*
3
5
7
0
0
0
0
0
3
5
7
Press any key to continue...

*/