Creating Arrays
Arrays are variables grouped together under a common name. The term array should be familiar to you—think of a salesperson showing off her array of products or a game show with a dazzling array of prizes. Like variables, arrays are created by stating the type of variable being organized into the array and the name of the array. A pair of square brackets ([]) follow the type to distinguish arrays from variables.
You can create arrays for any type of information that can be stored as a variable. For example, the following statement creates an array of string variables:
String[] naughtyChild;
Here are two more examples:
int[] reindeerWeight;boolean[] hostileAirTravelNations;
The previous examples create arrays, but they do not store ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access