
CSC 1350 Sep. 7
Rectangle rect1;
Rect1 = new Rectangle(10, 5, 80, 100);
Rectangle rect1 = new Rectangle (10, 5, 80, 10);
Accessor and Mutator Methods
Accessor method: does not change the state of its implicit parameter:
- Double width = box.getWidth();
Mutator method: changes the state of its implicit parameter:
- Box.translate(15, 25);
The API Documentation
API: Application Programming Interface
API: documentation: lists classes and methods in the Java library
Packages
Package: a collection of classes with a related…
Object References
Object reference: describes the location of an object
The new operator returns a reference to a new object:
- Rectangle box = new Rectangle();
Multiple object variables can refer to the same object:
- Rectangle box = new Rectangle (5, 10, 20, 30);
- Rectangle box2 = box;
- Box2.translate(15, 25);
Primitive type variables ≠ object variables