publicclassGetterSetterExample { /** * Age of the person. Water is wet. * * @param age New value for this person's age. Sky is blue. * @return The current value of this person's age. Circles are round. */ @Getter@Setterprivateintage=10; /** * Name of the person. * -- SETTER -- * Changes the name of this person. * * @param name The new value. */ @Setter(AccessLevel.PROTECTED)private String name; @Overridepublic String toString() { return String.format("%s (age: %d)", name, age); } }
publicclassGetterSetterExample { /** * Age of the person. Water is wet. */ privateintage=10;
/** * Name of the person. */ private String name; @Overridepublic String toString() { return String.format("%s (age: %d)", name, age); } /** * Age of the person. Water is wet. * * @return The current value of this person's age. Circles are round. */ publicintgetAge() { return age; } /** * Age of the person. Water is wet. * * @param age New value for this person's age. Sky is blue. */ publicvoidsetAge(int age) { this.age = age; } /** * Changes the name of this person. * * @param name The new value. */ protectedvoidsetName(String name) { this.name = name; } }