+ 1
What is the difference between constructor and method
2 ответов
+ 1
Constructor is called when an object of the class is created. Method needs to be called manually.
example:
constructor of class A gets called when object of the class is created:
A objName = new A(parametersForConstructorIfAny);
then you can call method in the class:
objName.someMethod();
0
in constructor u can"t have return type