How do I generate getters and setters?
Author: Deron Eriksson
Description: This tutorial describes how to generate getters and setters in Eclipse.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0)
To generate getters and setters, I right-click the editor and go to Source → Generate Getters and Setters.
This brings up the Generate Getters and Setters window. This window allows you to select which getter and setter methods you want to have automatically generated for which member variables. I clicked Select All and clicked OK.
Back in the Java editor, we can see that Eclipse has generated getter and setter methods for all the member variables, as expected.
As a keyboard shortcut, normally I hit Alt-Shift-S followed by R to bring up the Generate Getters and Setters window.