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!"
请先登录再写评论。
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.
But it only works, if the parameter is not used.
Tom