How do you force Eclipse to prompt you to create a getter and setter when it doesn't do it automatically?

南楼画角 提交于 2019-12-24 10:31:57

问题


I added two private fields to my Java class.

Eclipse prompted me to automatically create a getter and setter for one of them.

How do I get it to do the same for the other one that it 'forgot' about?


回答1:


editor view -> right click -> source -> generate getters and setters




回答2:


Fastest way for people that don't need a mouse anymore: with an editor in focus, press ALT+s, r.




回答3:


Yet another method: move your cursor over the field definition, press Ctrl+1, and select "create getter and setter for (field)".




回答4:


To create a getter/setter the fastest way is to type get (or set) + Ctrl + Space and you will see it in the pop-up proposal list.



来源:https://stackoverflow.com/questions/3822687/how-do-you-force-eclipse-to-prompt-you-to-create-a-getter-and-setter-when-it-doe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!