Why constructor name and class name is same
Table of contents
No headings in the article.
The main purpose of constructor is to initialize the object properties at the time of object creation if constructor name is same as class name then the JVM can automatically invoke the constructor. If we does not declare constructor name same as class name then the compiler either treated it as a method or may be it can throw an error
OR
Every class object is created using the new keyword so it must have the information about the class to which class object is created for this reason the constructor name should be same as class name.