0
If a constructor is used in a program in Java is getter and setter still relevant to use?
Java programing language question
3 Antworten
+ 5
Yes, both have different use. Suppose in future you will add 10 attributes in your class then you have to overload the constructor. But if you have setter also you can set them.
+ 4
Sunday Othniel Constructor is used to initial the attributes during creation of object. Where Setter are used to set the value of attributes after creation.
0
But what's the difference between getter, setter and constructor Raina Dhankhar ?