What is the eclipse shortcut for auto-generating a default and field constructor?

橙三吉。 提交于 2019-11-28 20:01:52
Juvanis

Type the first letter of your class, then press Ctrl+Space, Eclipse will list suggestions within a combobox. The topmost suggestion is the default constructor. Press Enter, it will be done. (I'm using Eclipse Juno and it works.)

LuGo

Alt+Shift+s and then o opens the Generate Constructor using Fields dialog.

Goto Source ---> Generate constructor using Fields

Under Source Title bar, select the Generate constructor using Fields option.

Or

Ctrl+Space which displays the various suggestions possible, from there you can go for the default contructor.

Ways to Generate default Constructor -
1) Press Ctl + Space

Ways to Generate field Constructor -
1) Press Alt + Shift + S + O
2) Right click -> Source -> Generate Constructor using field
3) Go to Source menu -> Generate Constructor using field
4) Go to Windows menu -> Preferences -> General -> Keys (Write Generate Constructor using field on text field)

When you hit CTRL-SPACE inside your class definition, you will see a drop down. First option is your Constructor.

Or you could type Ctrl + 3 and type GCUF, what means. Generate Constructor Using Field. Do almost the same to generate getters and setters: Type Ctrl + 3 and type GGAS, what means, Generate Getters And Setters

For Mac Users it is

Option + Command(⌘) + S or

Command(⌘) + Option + S will open the pop up.

I think CTRL + 3 is great.

GCFS - generate constructors from a superclass. GCUF - generate constructor using fields. GGAS - generate getters and setters.

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