Is there a way to automatically generate getters and setters in Eclipse?

I am working on a new Android project ( Java ), and created an Object with a large number of variables. Since I am planning to add getters and setters for all of them, I was wondering: is there a shortcut in Eclipse for automatically generating the getters and setters in a given class?


Bring up the context menu (ie right click) in the source code window of the desired class. Then select the Source submenu; from that menu selecting Generate Getters and Setters... will cause a wizard window will appear.

Source -> Generate Getters and Setters...

Select the variables you wish to create getters and setters for and click OK .


Right click -> Source -> Generate setters and getters

但为了使它更加方便,我总是将它映射到Windows -> Preferences -> General -> Keys ALT + SHIFT + G Windows -> Preferences -> General -> Keys


In Eclipse Juno, by default, ALT+SHIFT+S,R opens the getter/setter dialog box. Note you have to press all 4 keys.

链接地址: http://www.djcxy.com/p/23674.html

上一篇: Android开发人员:避免内部获取者/设置者?

下一篇: 有没有办法在Eclipse中自动生成getter和setter?