Is there a way to automatically generate getters and setters in Eclipse?

Phil picture Phil · Aug 28, 2011 · Viewed 304k times · Source

I am working on a new Android project (Java), and created an Object with a large number of variables. Since I am planning to add getters and setters for all of them, I was wondering: is there a shortcut in Eclipse for automatically generating the getters and setters in a given class?

Answer

Hagai Cibulski picture Hagai Cibulski · Aug 28, 2011

Bring up the context menu (i.e. right click) in the source code window of the desired class. Then select the Source submenu; from that menu selecting Generate Getters and Setters... will cause a wizard window to appear.

Source -> Generate Getters and Setters...

Select the variables you wish to create getters and setters for and click OK.