Create Getters and Setters

This dialog lets select the getter and setter methods to create.

Use Generate Getters and Setters from the Source menu or the context menu on a selected field or type, or a text selection in a type to open the dialog. The Generate Getters and Setters dialog shows getters and setters for all fields of the selected type. The methods are grouped by the type's fields.

The names of the getter and setter methods are derived from the field name. If you use a prefix or suffix for fields (e.g. fValue, _value, val_m), you can specify the suffixes and prefixes in the Code Style preference page (Windows > Preferences > Java > Code Style).

When pressing OK, all selected getters and setters are created.

Option

Description

Select getters and setters to create

A tree containing getter and setter methods that can be created. Getters and setters are grouped by field their associated field. 

Select All

Select all getter and setter methods

Deselect All

Deselect all getter and setter methods

You can control whether Javadoc comments are added to the created methods with the Generate method comments option at the bottom of the dialog.

Related tasks

Generating getters and setters
Source actions