A Java object is a block of memory that is used to store all the instance variables.
In Java, we use “new” keyword to create new objects and allocate memory at run time.
We can create an object from a class by following 3 steps:
- Declaration: It is declaration of a variable with name and object type.
- Instantiation: It is instantiation of an object using new keyword.
- Initialization: It is initialization of a new object using the “new” keyword followed by a constructor call.
// Declaration Square sq; // Instantiation sq = new Square(); // Initialization sq.length = 7;