Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
Constructor is the point of initialisation of any object. If an explicit constructor is not given, the class has a default no arguments constructor that is internal to it which would be called when the object is created using the new operator. Constructor does not have a return type.
In contrast a method is created by the user to do some actions on the object. It is explicitly invoked on the object. It has a return type.
The important difference between constructors and methods is that constructors create and initialize objects that don't exist yet, while methods perform operations on objects that already exist.