Class Object and Method
 
Instantiating an Object
 
The new operator instantiates a class by allocating memory for a new object of that type. new requires a single, postfix argument: a call to a constructor.
 
Each Java class provides a set of constructors used to initialize new objects of that type. The new operator creates the object, and the constructor initializes it.
 
Here's an example of using the new operator to create a Rectangle object:
new Rectangle(100, 200);
 
 
Here, Rectangle(100, 200) is the argument to new. The new operator returns a reference to the newly created object.
 
This reference can be assigned to a variable of the appropriate type, as here.
Rectangle rect = new Rectangle(100, 200);