Still busy writing setters and getters method manually? Actually, Eclipse IDE is able to help you generate the setters and getters method automatically, and this feature is bundle with Eclipse IDE long time ago, surprisingly, many Java developers are not aware of it?

See following steps to show you how.

1. Java Pojo

A simple User.java, with 4 fields, but no getters and setters method.

Java pojo

2. Generate It

Right click on the file, select “Source” –> “Generate Getters and Setters…

getters and setters in eclipse ide

Choose which field you want to generate, and click on “OK” button.

getters and setters in eclipse ide

3. Done

All selected getters and setters methods will be generated automatically.

getters and setters in eclipse ide

So, don’t create those methods manually, it waste time, use IDE.

Tags :
Founder of Mkyong.com and HostingCompass.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

Related Posts

Popular Posts