Question: what are getters and setters for?
Answer: Getters and Setters in Java Explained. Getters and setters are used to protect your data, particularly when creating classes. For each instance variable, a getter method returns its value while a setter method sets or updates its value. ... Getters and setters allow control over the values.