Can I Generate Attributes from Constructor?

Hi

Is there a nice quick way of generating the Class attributes and assignments
from a Constructor signature?

E.g. from:

public Foo(String name, String somethingElse, ...)
{
}

to:

public class Foo
{
private String name;
private String somethingElse;

public Foo(String name, String somethingElse, ...)
{
this.name = name;
this.somethingElse = somethingElse;
....
}
}

Thanks
Shane

-


shanemingins@yahoo.com.clothes
remove clothes before replying

"If you really want something in this life, you have to work for it - Now
quiet, they're about to announce the lottery numbers!"


2 comments
Comment actions Permalink

Yes, it's not as automatic as some other things in IDEA, but you can place the cursor in the name of each parameter, press Alt+Enter, and it suggests "Create Field for Parameter" which does exactly what you want. You have to click through a bunch of dialogs, at least one per field, which is kind of annoying, but it's pretty easy otherwise.

0
Comment actions Permalink

But it only works, if the parameter is not used.

Tom

0

Please sign in to leave a comment.