Do you need getters and setters if you have a constructor?

In simple terms: Use constructor if you think initialization is mandatory before you can use the object . Use setter method when initialization of variable is non-mandatory to use the object.

Sizin İçin Seçtik  What are the two attributes of a class in Java?

Leave a Reply

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