Object
+ shortcut
➜ Object object = new Object();
Whether there is such shortcut?
Object
+ shortcut
➜ Object object = new Object();
Whether there is such shortcut?
new Obj
, Tab to complete to new Object()
, Ctrl+Alt+V (Refactor
| Introduce Variable):
Object o = new Object();
Change name if needed and press Enter to confirm.
For the more convenient solution utilizing the live templates feature please check the answer below from @MarcG.
As of 2017, improving on @aleksander's answer, I believe the best way to create a new object as efficiently as possible in Intellij IDEA, is this (click to enlarge):
Settings > Live Template
. +
to the right of the window, to add a new Live Template. n
or newo
). Description could be new Object
.$Clazz$ $obj$ = new $Clazz$($END$);
Edit Variables
button, and the fill in the Clazz
and obj
Expression and Default Value as shown in the picture above.Define
next to No applicable contexts
, to define Java > Statement
as the context.Now test it: Go to the editor, type n
and then the TAB
key.
You can define your own Live Template. Press Crtl+Alt+Shift+S (go to Settings), then go to tab Live Templates and write down something similar to below and you will have new shortcut (newo+tab).