Usage of Arrays

In Java, the .length attribute allows us to obtain the size of the array. This naming varies depending up on the language one is using, and not all languages support it, but it is very handy!

Some languages have many other array functions as well, such as summation for integer arrays. You can find out which functions your language supports another time.


Java Example Results

This month is Apr
month: Jan
month: Feb
month: Mar
month: Apr
month: May
month: Jun
month: Jul
month: Aug
month: Sep
month: Oct
month: Nov
month: Dec


The first line of the output tells us which month it is. In our code, we asked for the month indexed by the number 3 (4th month, start at zero remember!). Therefore, it printed out "Apr", the 4th month. It then when on to print all months from 0 to length - 1 (index 11).