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.
If in this case it's better to use the constructor or the method
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Sachin SinghRank #66 · 26.2K reputationPosted Sep 12, 2022, 4:17 AM EDT
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.