How to automatically generate getters and setters in Android Studio

后端 未结 15 1224
太阳男子
太阳男子 2020-12-02 04:15

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

15条回答
  •  北海茫月
    2020-12-02 05:14

    You can generate getter and setter by following steps:

    • Declare variables first.
    • click on ALT+Insert on keyboard placing cursor down to variable declaration part
    • now select constructor and press Ctrl+A on keyboard and click on Enter to create constructor.
    • Now again placing cursor at next line of constructor closing brace , click ALT+INSERT and select getter and setter and again press CTRL+A to select all variables and hit Enter.

    That's it. Happy coding!!

提交回复
热议问题