Wednesday, 17 December 2014

// The "MultiDimensionalArraysExample8" class.  Page 324.
// (from the Carter book)

// Example 8:

public class MultiDimensionalArraysExample8
{
    public static void main (String[] args)
    {
        // Suppose that we were to declare a 2-dimensional array of type
        // double called "table" (with 40 rows and 60 columns maximum):

        double[] [] table = new double [40] [60];

        // We could then call the "process" method from "main" by writing
        // the following line and passing "table[20]" to the "process" method:

        process (table [20]);  // this argument passes 20 rows of "table"
        // to the "process" method (see below).

    } // main method


    // Suppose that a program had a method with the following header
    // defined:
    public static void process (double[] row)
    {
        // insert your method code here.
        // This works because "table [20]" is really a reference to a one-dimensional
        // array of double values, and that is an exact match to the type double
        // one-dimensional array parameter called "row".

    } // process method

} // MultiDimensionalArraysExample8 class

No comments:

Post a Comment