Create automatically only getters in Eclipse

前端 未结 3 1292
忘掉有多难
忘掉有多难 2021-02-14 18:55

In Eclipse is it possible to create automatically Getters and Setters for a field. But I have a lot of private fields for which only getters should exist. Is somewhere in Eclips

3条回答
  •  太阳男子
    2021-02-14 19:47

    One more (may be nasty) way of creating only getters is:

    1. Create the member variables with final modifier (such as private final int hoursSpentInSO)
    2. While in editor, and press Alt + Shift + s, r (Press the r key after a slight delay)
    3. You will get only getters for those final fields, press OK
    4. Once getters are generated, remove the final modifier (if required)

提交回复
热议问题