You are here

Array Variables

15 January, 2016 - 09:02
Available under Creative Commons-ShareAlike 4.0 International License. Download for free at http://cnx.org/contents/402b20ad-c01f-45f1-9743-05eadb1f710e@37.6
- Array variables are declared like other variables: a declaration consists of the array's type followed by the array's name. For example, double[][] matrixOfDoubles; declares a variable whose type is a two-dimensional array of double-precision floating-point numbers.
- Declaring a variable of array type does not create an array object. It only creates the variable, which can contain a reference to an array.
- Because an array's length is not part of its type, a single variable of array type may contain references to arrays of different lengths.
- To complicate declarations, C/C++-like syntax is also supported, for example,
  double rowvector[], colvector[], matrix[][];

This declaration is equivalent to
double[] rowvector, colvector, matrix[]; or
double[] rowvector,
colvector;
double[][] matrix;

Please use the latter!