Java Objects

Java Objects

An object of a class defined by attributes and behaviors.
An object is an instance of the class.
Attributes are characteristics that may change.
Behaviors are actions that the object can do.

Declaration

An object is declared by writing the class name followed by the object name.
nameClass nameObject;

Instantiation

An object is instantiated using the new operator.
nameClass nameObject = new ();

Initialization

An object is initialized via constructors class.
nameObject = new nameClass ([constructor arguments]);

Anonymous objects

Anonymous objects are used only for initialization of other objects.
Rectangle = new Rectangle square (new Point (0,0) New Dimension (50, 50));