Constructor in Java

java dev.to

1) What is Constructor? A constructor is a special method in Java used to initialize objects. It is automatically called when an object of a class is created. Name: A constructor must have the same name as the class. No Return Type: A constructor does not have a return type, not even void. 2) Types of Constructor Default Constructor: A default constructor is a constructor with no parameters. The Java compiler makes a default constructor if we do not write any constructor in our program.

Read Full Tutorial open_in_new
arrow_back Back to Tutorials