2
Reply

What do you mean by Constructor in Java? How do we define that?

Rohit Gupta

Rohit Gupta

5y
1.3k
0
Reply

    A constructor is like a special method in Java, which is used to initialize an object of a Java class and Constructor is very important for every Java class and if we don’t declare the constructor, the compiler creates a default constructor of a Java class.

    A constructor must be the same name of a Java class. It does not have a return type.

    For a detailed tutorial on Constructors in Java, visit
    https://www.c-sharpcorner.com/article/a-complete-java-classes-tutorial/

    It's the inner method of a class the let the class be created, it has the same name of the class and it may have parameters or not.