Object: Creating Objects

Creating Objects

Point originOne = new Point(23, 94);
Rectangle rectOne = new Rectangle(originOne, 100, 200);
Rectangle rectTwo = new Rectangle(50, 100);
  • A class provides the blueprint for objects; you create an object from a class.
  • The new operator requires a single, postfix argument: a call to a constructor.
  • The new operator returns a reference to the object it created.
Each statement for creating objects has three parts.

Declaring a Variable to Refer to an Object

Point originOne;

Object: Creating Objects — Structure map

Clickable & Draggable!

Object: Creating Objects — Related pages: