When a number of items that belong together are needed they should be stored in an array. Square brackets are used to create an array. Below two arrays are created, an empty one named rows, and one holding four first names.
var rows = ;
var names = ['Adam', 'Bill', 'Chad', 'David'];
Arrays have an attribute called length.
out.println("rows has " + rows.length + " items)
out.println("names has " + rows.length + " items)
The console will display.
>>rows has 0 items
>>names has 4 items
To append another object to an array the method 'push' is used.
The square bracket notation is used to get items within an array. The indexes start at the value 0, as is usual for computer programming.