+ 2
Constructors
How can I execute the body of ïżŒ constructor from the method in the same class?
5 Answers
+ 1
Reema you cannot call a constructor of a class from the method in the same class.
You can use this() to call a constructor from another overloaded constructor within the same class or use super() to call a parent class constructor.
+ 1
Yes but only between inherited classes. You can only call a constructor from inside another constructor. In your case, you will call it through the super().
Let me know if you need an example.
0
Declaring it in the Pubkuc class body
Importing Object Library and class before class declaration
Using or Calling it inside the body
0
gave me exaple
0
okay thank you but can i call constructor from another class ??