Java Getters and Setters

后端 未结 17 1577
终归单人心
终归单人心 2020-12-01 15:27

Is there a better standard way to create getters and setters in Java?

It is quite verbose to have to explicitly define getters and setters for each variable. Is ther

17条回答
  •  长情又很酷
    2020-12-01 15:58

    I'm not sure if you'd consider it 'standard', but Project Lombok addresses this problem. They use annotations to replace much of the verbosity of Java.

    Some people are looking at alternative Java sibling languages, such as Groovy or Scala. I'm afraid it will take some years -if at all- before the JSR figures out a "standardized" way to "fix" this in Java proper.

提交回复
热议问题