| To move rect to a new location using its move method, we write this: |
| rect.move(15, 30); |
| |
| This Java statement calls rect's move method with two integer parameters, 15 and 30.
It moves the rect object because the rect method assigns new
values to origin.x and origin.y, and is equivalent to the assignment statement used previously:
|
| rect.origin = new Point(15, 30); |
| |
| |
| The notation used to call an object's method is similar to
that used when referring to its variables: we append the
method name to an object reference with an intervening period (.).
Also, we provide any arguments to the method within enclosing parentheses.
If the method does not require any arguments, use empty parentheses. |
| |
| objectReference.methodName(argumentList); |
| or |
| objectReference.methodName(); |
| |
| |