How to use Object Class Constructor
Seriesjava.lang.Objectpart 1 of 2
- How to use Object Class Constructor
- How to use equals method in java.lang.Object class
Before going into the Object constructor let us know what is a constructor?
A class contains constructors that are invoked to create objects from the class blueprint. Constructor declarations look like method declarations except that they use the name of the class and have no return type.
Object class had one constructor with no parameters.
public Object()
Example Code Snippet:
public class ObjectConstructorInDetail {
public static void main(String[] args) {
//Object() constructor creates an instance of Object class
Object object = new Object();
}
}