0 votes
in JAVA by
What is the use of constructor in java?

1 Answer

0 votes
by

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.

Related questions

0 votes
asked Oct 27, 2020 in JAVA by sharadyadav1986
+1 vote
asked May 30, 2020 in JAVA by Robindeniel
...