Android Studio is an advanced and Official Integrated Development Environment for developing Android Apps. It is based upon IntelliJ IDEA and offers some cool features which are really useful for android developers. In this article we will talk about the code generation in Android studio.
Generating Getters And Setters Automatically
If you have class with private fields, you will have to write code for generating the getters and setters but if you are using android studio then it will do the trick for you.
Consider the following java class, we have two private fields here.
To generate the getters and setters automatically follow the following steps.
- Right Click anywhere inside your class opening and ending braces in the editor or press Alt + Insert keys.
- Select Generate and you will see a menu like below, from the menu select Getter and Setter.
- This will open up another prompt, where you will have to select the fields for which you want to generate the getters and setters.