Why use setters in java instead of constructors? [duplicate]
Because you can change the value later for the same instance. For example, let’s assume a person with the following class: public class Person { String firstName; String lastName; public Person(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } public void setLastName(String lastName) { this.lastName = lastName; } } Imagine there is … Read more