Hello! I have a List of type *Observations*, I want to know if in this case it's better to use the constructor or the method *setObservation* to create an instance of this type.
Loading
Hello! I have a List of type *Observations*, I want to know if in this case it's better to use the constructor or the method *setObservation* to create an instance of this type.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sachin SinghPosted Sep 12, 2022, 8:17 AM
To set or initialize variable, List or object use constructor.
Treat methods as a functional area to write code for a specific functionality, Methods must do some some opertions apart from initialization of members where as Constructors are not meant to write code to develop functionality of software they are just for inialization, dependency injection etc.