Should I use setters in constructor Java?

You should not call getters and setters from the constructor. A constructor constructs the specific class in which it is defined. It is its job to initialise the fields because – well – nothing else will. The only way to guarantee initialising the fields is to assign them.

Sizin İçin Seçtik  1 gram altın kaça bozdurulur?

Leave a Reply

Your email address will not be published. Required fields are marked *