// (from the Carter book)
//
// Example 6:
//
// 1. The following declarations are ALL VALID (see below):
public class MDArrayExample6
{
public static void main (String[] args)
{
// (6a): (all dimensions' sizes are specified):
char[] [] [] goodOne = new char [5] [6] [3];
// (6b): (the last 2 dimensions' sizes are not specified):
byte[] [] [] goodTwo = new byte [20] [] [];
// (6c): (the last dimension's size is not specified):
double[] [] [] goodThree = new double [50] [100] [];
// (see below program for NOTES)
} // main method
} // MDArrayExample6 class
//
// Example 6: (continued) --> NOTES:
//
// (6a): This first declaration creates an array of 5 * 6 * 3 = 90 char
// elements or, more accurately, five sets of six sets of 3-element
// char arrays.
// (6b): This second declaration creates 20 arrays of type byte [][]. Each
// of these 20 arrays (called "goodTwo[0], goodTwo[1], and so on) will all
// be initialized to null (because no size is specified for the other 2
// dimensions).
// (6c): This third declaration creates an array of 50 references to arrays of
// 100 references to arrays with elements of type double. These 5,000
// array references will all be set to null (because no size is specified for
// the last dimension).
No comments:
Post a Comment