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.


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


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


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));