I was wondering is there is a keyboard shortcut (in IntelliJ) for creating a new instance of an object. e.g. when I type PersonObject personObject = new PersonObject, is there a way to type this faster? Instead of writing it out, or using autocomplete.
The Answer by racraman looks like a good one. An alternative is to type part of the line, and let IntelliJ finish it.
Introduce local variable
You can type just the
new PersonObject part, and let IntelliJ write the variable declaration and assignment.
… then either:
Refactor > Extract/Introduce > Variablemenu item, or
- Press keyboard shortcut shown in this Answer.
IntelliJ fills in the rest. You end up with:
PersonObject personObject = new PersonObject();
See the documentation page, Extract/Introduce variable.