How to generate a void method in IntelliJ IDEA?

To create a new method from usage in the code like:

...
someMethodName()
...

AltEnter on the red code:

Create Method

It’s also possible to type void methodName() and use Complete Statement (CtrlShiftEnter), it will become:

void methodName() {
    |
}

You could create your own Live Template as @Makoto answered, but programming by intention seems to be more natural. When you don’t have a method, you write code that will use it, then create the method from the intention action – this way IDEA will generate the method signature automatically according to the parameters and return type in the not yet existing method usage, like String result = someMethod(stringParam);.

Finally, it is worth nothing that in IntelliJ IDEA main() method can be generated using psvmTab.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)