simple question: What is the shortcut to autocomplete () { } in Java Eclipse?
I've been searching like crazy to find what the key combination for this is.
simple question: What is the shortcut to autocomplete () { } in Java Eclipse?
I've been searching like crazy to find what the key combination for this is.
Put your mouse cursor within a class, write your method name and press Ctrl+Space. It will show you the suggestion whether you want to create new method stub (method). Press Enter and it will generate the method definition with an empty body.
Example: hello
(Ctrl+Space) and then Enter key
Output:
private void hello() {
// TODO Auto-generated method stub
}
This way you can generate a method stub. Works for methods to create within functions.
However there is no existing way to just generate only "(){}" in eclipse. It's kind of copy paste thing which should forever remain copied somewhere somehow in eclipse so that you just paste it with some shortcut keys inside the eclipse IDE
To auto-close an opened brace or parentheses, see Dawood ibn Kareem's answer below