Java Getters and Setters

后端 未结 17 1534
终归单人心
终归单人心 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 16:20

    Use your IDE to generate it for you and try to minimize the amount of getters/ setters that you have - you will likely enjoy the added benefit of immutability.

    I like the C# syntax for properties, I think it's pretty and clean, and pretty clean.

提交回复
热议问题