Friends! I understood how setters, getters and designers work. But I did not understand one thing:
public class Person { private String name; public Person(String name){ this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } } public class User { public static void main(String[] args) { Person person = new Person("Василий"); System.out.println(person.getName()); person.setName("Леонид"); System.out.println(person.getName()); } } Why do we need setters if you can specify everything in the constructor (in the parameters)? Maybe there are some pitfalls or different situations?