


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Object-Oriented Design & Patterns Chapter 1 Notes
Revised 1/23/
Here we will skip the following sections because they have (or are) being considered at other times, such as in the lab: 1.1 (in Eclipse & Java tutorial) 1.2 (later) 1.9 (in Lab 1) 1.14 (later)
Greeter mine = new Greeter(); mine.function( param );
i. Here there is an implicit parameter for mine ii. The “special name” for the implicit parameter is “this”, e.g., this.mine iii. Here param is the explicit parameter b. A method can change the state of an object if that object is an explicit parameter for the method (Example 01) c. A method cannot change the value of a parameter, which is either a reference to an object or a primitive type (Example 01) d. Java uses “call by value” when passing parameters (no call by reference)
f. Try block and catch block try {
... code that may generate an exception } catch ( IOException exception ) { ... handle the exception }
while (iterator.hasNext() ) { String anElement = iterator.next(); if( anElement.equals( “mine” ) { Iterator.remove(); }
int[] numbers = new int[5];
Assume that there is a class called House, then
House[] houses = new House[20]
c. When an array is constructed its elements are set to zero, false, or null, depending upon the kind of array element d. You can use the “for each” loop to traverse all elements in the array e. You can initialize an array when it is declared, as follows:
int[] numbers = { 100, 200, 300, 400 } f. Arrays can have multiple dimensions, as follows:
int[][] matrix = new float[ 5 ] [ 8 ];