What is the point of getters and setters? [duplicate]
Multiple reasons: If you allow field access like shape.x = 90 then you cannot add any logic in future to validate the data. say if x cannot be less than 100 you cannot do it, however if you had setters like public void setShapeValue(int shapeValue){ if(shapeValue < 100){ //do something here like throw exception. } … Read more