





Multidimensional Array
Posted by kmilton7,
02 July 2012
·
2222 views
array novice multidimensional
An array allows us to store a set of values of a similiar data type. A multidimensional array allows us to store a set of sets of a particular data type (although you can have an array of one type containing an array of some other type, i think, hey it's a beginner's blog
).
Ok, so here is an example of a 2 dimensional array containing day of the week and the presence of rain on that day. Here is the code:
The output is:
Day Precipitation
Monday Rain
Tuesday No Rain
.
.
.
Sunday No Rain

Ok, so here is an example of a 2 dimensional array containing day of the week and the presence of rain on that day. Here is the code:
String myWeek [] []; myWeek [0] [0] = "Monday"; myWeek [0] [1] = "Rain"; . . . myWeek [6] [0] = "Sunday"; myWeek [6] [1] = "No rain"; System.out.print ("Day\tPrecipitation"); for (int i=0; i < 7; i++){ for (int j=0; j < 2; i++){ System.out.println (myWeek [i] [j] + "\t"); } System.out.println; }
The output is:
Day Precipitation
Monday Rain
Tuesday No Rain
.
.
.
Sunday No Rain