0

Up until today, I created my objects with getters/setters of the form:

private String mode;
public String getMode() { return this.mode; }
public void setMode(String mode) { this.mode = mode; }

But sometimes, API introduced another names for getters/setters:

private String mode;
public String mode() { return this.mode; }
public void mode(String mode) { this.mode = mode; }

Especially, since Java 17, a Record shows its members with getters not having a get prefix.

Does the removal of get/set prefixes to the getters/setters respond to a special need?

Do conception rules exists to choose one form in preference to the other?

Marc Le Bihan
  • 2,308
  • 2
  • 23
  • 41

0 Answers0