+ 2

Constructors

How can I execute the body of ïżŒ constructor from the method in the same class?

8th Apr 2020, 4:28 PM
Reema
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.
8th Apr 2020, 5:13 PM
Avinesh
Avinesh - avatar
+ 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.
8th Apr 2020, 5:32 PM
Avinesh
Avinesh - avatar
0
Declaring it in the Pubkuc class body Importing Object Library and class before class declaration Using or Calling it inside the body
8th Apr 2020, 4:36 PM
Arpan Bhattacharya
Arpan Bhattacharya - avatar
0
gave me exaple
8th Apr 2020, 5:12 PM
Reema
0
okay thank you but can i call constructor from another class ??
8th Apr 2020, 5:15 PM
Reema