Summary of Class Presentation for June 11, 1999 Most of the period was spent looking at examples of arrays. Java has only two aggregation mechanisms in the language itself: classes with their objects, and arrays. There are some other collections provided in core libraries, but not in the language alone. Arrays are declared in a statement like int goerge[]; This statement indicates that there will be an array of integers named goerge, but does not specify its size nor does it allocate any storage for the array. Both are done with a statement like goerge = new int[10]; Both the declaration and the storage assignment along with an assignment of values can be done in a single statemen like int sam = new int[ ] = { 11, 14, 3, 19, 5, -3, 11, 0,4}; which sets up a 9 element array with subscripts 0 - 8. Array elements are referenced using subscripts: sam[3]. An array can be passed to a method as a parameter by giving the array name without the [ ] . For example, w( z, t) can pass the entire t array to the function w ( along with another parameter, z. Since arrays are actually references to their storage (just like objects), the passing of an array as a parameter results in a copy of the reference being made for use in the called method, Since the called method can use this reference to access the original elements of the array, the called method can change the array values. The length of an array is always available as the length attribute of that array. For example, if the array is named q, q.length is the length of the array. To summarize parameter passing, there are three cases: 1. passing of individual primitive values such as integers or floats or chars that is done by value. The called method cannot affect the original values of the parameter. 2. passing of objects. The reference to the object data and methods is copied and passed. Through this reference, the object data can be accessed. 3. passing of arrays. The reference to the array data is copied and passed. Through this referenc, the array data can be accessed and modified. Multiple dimensional arrays can be declared and defined. Either they or any slice of them can be treated as an array.