What is an eclipse java declaration ad label?

Is there any eclipse shortcut to position a new object? For example. I would like to type:

Object zzz = 

and it will be finished for me as follows:

 Object zzz = new Object(); 

with the void parameter, of course. I will wait for answers .. thanks to the people.

+7
java eclipse
source share
4 answers

Try the "new" template:

1) type new and then ctrl + space.

2) Select the option "create a new object"

3) Insert the name and parameters of the class (if necessary)

If you do not need parameters, you can create a template yourself (settings templates-> java-> editor->). Give it a unique name and set for the template:

 ${type} ${name} = new ${type}(); 
+8
source share

An alternative is to write a new Object () and then use the Extract Local Variable (Alt + Shift + L) refactoring, in cases where I need to pass parameters to the constructor, I think this works well.

+3
source share

If you type Object zzz = new , then <crtrl> + <space>, which calls intellisense, and you can just press <enter> and you will get the first constructor available.

+2
source share

Eclipse comes with the default new template. To use it, enter โ€œnewโ€, then Ctrl-space (or a sequence of autofill keys) and select โ€œnew - create a new objectโ€. You will then be prompted to enter a string into a string, a variable name, and arguments. Use the tab to go to the next field.

0
source share

All Articles