I had looked up solutions here C# shortcut or shorthand getter setter but when I implement one of solutions
visual studio generates code like
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
what I want vs auto getter setter generator is to create getter setter for all of my variables and depending using their name like
private int id;
public int Id
{
get { return id; }
set { id= value; }
}
Is this possible?
You just simply press Alt + Ins in Android Studio. After declaring variables, you will get the getters and setters in the generated code.
Right click on the file, select “Source” –> “Generate Getters and Setters…” Choose which field you want to generate, and click on “OK” button.
You may use lombok - to manually avoid getter and setter method. But it create by itself. The using of lombok significantly reduces a lot number of code.
Yes, Just create a field then Refactor->Encapuslate Field
. Shortcut is ctrl + R, E
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With