3 ms·
Besides, getters and setters are debuggable. They allow you for setting breakpoints, adding Log calls etc... Not so in case of fields. It would be nice to have
by V-2 12y ago
Besides, getters and setters are debuggable. They allow you for setting breakpoints, adding Log calls etc... Not so in case of fields.
It would be nice to have some syntax sugar for defining properties more tersely though, like in C#.
- organsnyder 12y agoProject Lombok allows you to use annotations to create getters and setters: @Getter private String author; @Getter private String title; Or, on the class, here with a fluent (non-JavaBean) API: @Data @Accessors(fluent = true) // experimental public class Article { private String author; ... }