/*
   Compare "primitive data types" with "reference data types".

   Compare "call by name" with "call by reference".
*/

public class Array7
{

   public static void main( String args[] )
   {
       final int ARRAY_SIZE = 10;

       //construct an array and point a reference to it
	   int[] myArray = new int[ARRAY_SIZE];

	   //declare an integer variable
	   int myInteger;

	   //print out the array
	   for (int i = 0; i < myArray.length; i++)
	   { System.out.print( myArray[i] + " " );
	   }
	   System.out.println();

	   //print out the integer
	   System.out.println( myInteger );

       //use a method to initialize the array and the integer
       //what does this method "return"?
       initializeRandomly( myArray, myInteger );

	   //print out the array again
	   for (int i = 0; i < myArray.length; i++)
	   { System.out.print( myArray[i] + " " );
	   }
	   System.out.println();

	   //print out the integer again
	   System.out.println( myInteger );

   }//main

   public static void initializeRandomly( int[] anArray, int anInteger )
   {
       //initialize the array with random integers
   	   for (int i = 0; i < anArray.length; i++)
   	   { anArray[i] = (int) (100*Math.random()); }

   	   //initialize the integer with a random integer
   	   anInteger = (int) (100*Math.random());

    }//initializeRandomly

}//Array7

/*
This program shows that reference data types (like an array) are initialized
by the Java system when they are created at runtime, but primitive data types,
like an integer, are not initialized at runtime, and the compiler will not let
you use them until you explicitly initialize them.

This program also demonstrates how a method can return a result by using "call
by reference", which is what methods use for reference data type parameters, but
a method cannot return a result when using "call by value", which is what methods
use for primitive data type parameters.
*/
