OnWorks Linux and Windows Online WorkStations


Free Hosting Online for WorkStations

< Previous | Contents | Next >

What Are Arrays?

Arrays are variables that hold more than one value at a time. Arrays are organized like a table. Let’s consider a spreadsheet as an example. A spreadsheet acts like a two-dimen- sional array. It has both rows and columns, and an individual cell in the spreadsheet can be located according to its row and column address. An array behaves the same way. An array has cells, which are called elements, and each element contains data. An individual array element is accessed using an address called an index or subscript.

Most programming languages support multidimensional arrays. A spreadsheet is an ex- ample of a multidimensional array with two dimensions, width and height. Many lan- guages support arrays with an arbitrary number of dimensions, though two- and three-di- mensional arrays are probably the most commonly used.

Arrays in bash are limited to a single dimension. We can think of them as a spreadsheet with a single column. Even with this limitation, there are many applications for them. Ar- ray support first appeared in bash version 2. The original Unix shell program, sh, did not support arrays at all.

Top OS Cloud Computing at OnWorks: