Search code examples
android-studioshortcut

How to automatically generate getters and setters in Android Studio


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


Solution

  • Using Alt+ Insert for Windows or Command+ N for Mac 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