TGMCians TGMCians -4 years ago 184
Java Question

How to automatically generate getters and setters in Android Studio

I am working on a Android application and created a model with a large number of variables. Since I am planning to add getters and setters for all of them.

Is there a shortcut in Android Studio for automatically generating the getters and setters in a given class?

Answer Source

Using Alt+ Insert in the editor, you may easily generate getter and setter methods for any fields of your class. This has the same effect as using the Menu Bar -> Code -> Generate...

enter image description here

and then using shift or control button, select all the variables you need to add getters and setters

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download