There´s any eclipse shortcut to stance a new object ? For example. I would like to type:
Object zzz =
and it would complete for me this way:
Object zzz = new Object();
with void parameter of course. I will wait answers.. thank you people.
There´s any eclipse shortcut to stance a new object ? For example. I would like to type:
Object zzz =
and it would complete for me this way:
Object zzz = new Object();
with void parameter of course. I will wait answers.. thank you people.
If you type Object zzz = new
and then <crtrl>+<space> that brings up intellisense, and you can just hit <enter> and you'll get the first available constructor.
Eclipse ships with a default template new
. To use it, type "new" then Ctrl-Space (or your autocomplete key sequence) and select "new - create new object." You will then be prompted in-line to fill in the type, variable name and arguments. Use tab to move to the next field.
Try the template 'new':
1) type new and then ctrl+space.
2) Choose the 'create new object' option
3) Insert the class name and parameters (if needed)
If you don't want the parameters, you can create a template yourself (preferences->java->editor->templates). Assign a unique name to it, and set the pattern to:
${type} ${name} = new ${type}();
An alternative is to write new Object() and then use the "Extract Local Variable" Refactoring (Alt + Shift + L), in cases where I need to pass in parameters to the constructor I find this works well.