Eclipse generate getters and setters and automatically apply them
问题 In my Java code I directly accessed some member variables. Now I want to refactor and use getter and setters. How can I make Eclipse automatically replace all direct assignments with setters and each access with a getter? Right click -> Source -> Generate Getters and Setters just creates the functions but does not apply them in the rest of the code. 回答1: Use the Refactor menu. It has an item "encapsulate fields" which generates getters and setters just as "Source -> Generate Getters and