Arrays

The next example uses an array to store the number of days in each month. We won't be using element 0, but it is easier to understand if January is element 1 and December is element 12.

CODE

Output:

#	Month	Days
1	January	31
2	February	28
3	March	31
4	April	30
5	May	31
6	June	30
7	July	31
8	August	31
9	September	30
10	October	31
11	November	30
12	December	31

Notice that the columns do not line up correctly. In the next example we use String.format to line up the columns.

NEXT: