What is the use of constructor in java?
A constructor is a block of code that initializes the newly created object. A constructor resembles an instance method in java but it’s not a method as it doesn’t have a return type. In short constructor and method are different(More on this at the end of this guide). People often refer constructor as special type of method in Java.
A constructor has same name as the class and looks like this in java code.
🔗Source: stackoverflow.com
🔗Source: Java Interview Questions and Answers