Search code examples
android-studioauto-generate

generate automatically getter and setter in Android Studio


When I programmed with Android Studio, it seems to me that is a way to generate automatically the getter and the setter of my new java class.

Can anyone tell me how to do it?


Solution

  • Open the class you want, right click anywhere in the code and chose the Generate option:

    enter image description here

    Then chose what you are trying to generate: setters, getters or both:

    enter image description here

    Then select the fields you want, and you're done.