READING CHAPTER 10 SECTION 1 "Array Basics" - *array* - feature supported by programming languages (PL) to manipulate a collection of values - Java: indexed collection of data values of the same type - declare an array [] ; []; - array - reference data type - amount of memory allocated to store an array varies with the number and type of values in it - use reserved word new for array memory allocation - but array is not considered an object - create an array of a given size = new []; - can combine declaration and allocation [] = new []; - use single identifier to refer to whole collection - *indexed expression* used to refer to individual values - *array element* individual value in an array - zero-based indexing - biggest index is size-1 - refer to the nth element of an array - n can be an expression []; - public constant length is the size of any array - necessary for iterating through an array using a for loop if the array size is not known in advance .length - initialize an array at the time of declaration - size of the array - do not specify - determined by the number of values in the list [] = {, , ... , }; - *fixed-size array declaration* - not always most efficient space usage - if end up needing more, must change and recompile the program - if end up using less, then wasting space - *variable-size array declaration* - can allocate arrays of various size by using a variable (initialized with user input) - can also use an expression Quick Check: 1. c and d are invalid 2. int sum = 0; for (int i = 0; i < 25; i++) { if (number[i] > 0) { sum += number[i]; } } 3. The first method prints out all the evenly indexed elements of the array, while what the second fragment prints depends on the values stored in the array.