|
Declaration e.g. int [] numbers; In the first case, numbers is a pointer to an array of unknown size of integers. In the second case, numbers is a pointer to an array that contains 10 integers. Arrays are 0 based, so the slots are numbered 0 through 9. Initially, each slot contains the default value (0) for an integer. In the third case, names is a pointer to an array of unknown size of String pointers. Initialization e.g. numbers[0] = 77; // initializes position 0 to 77 Declaration and Initialization e.g. int [] numbers = {1900, 1950, 2000}; Access e.g. numbers[0] = numbers[1] + numbers[2]; Useful Built-In Data Fields e.g. numbers.length // returns 3, the number of slots in the array |