I am using Eclipse EE IDE - Indigo. I filled in all my class variables and then right click on the page and select -> Source -> Generate Getters and Setters. This works fine but it puts the methods right on top of each other ex:
public String getValue1() {
return value1;
}
public void setValue1(String value1) {
$this.value1 = value1
}
public String getValue2() {
return value2;
}
public void setValue2(String value2) {
$this.value2 = value2
}
Is there any way to tell Eclipse to put a space between the methods when auto-generating?
Select "Javadoc -> Generate Getter/Setter Javadocs from Field Javadocs..." in the main menu of Eclipse or the context menu of the editor, and a dialog opens. The shortcut key is Ctrl+Shift+D. In the dialog select getters and setters for which you want to generate Javadocs and click "OK" button.
You can't make getter and setter methods static if you use any attributes or properties that aren't static.
The Java coding convention states that methods (getters and setters are methods) should be after constructors declarations. It just a convention and it exists to make code easier to read in general.
Yes. I tried this on Eclipse 3.7. It's a bit clunky, but it works.
Generate one getter or setter method using the right click option Source -> Generate Getters and Setters.
Manually add two blank lines after the method.
On the second blank line, use the right click option Source -> Generate Getters and Setters to generate the rest of the getters and setters.
After the getters and setters have been created, select the newly created methods and "format" the code (Ctrl+Shift+F).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With