+ 2

Why should we use getter & setter methods in Java??

Quick access on the variable's value!!

9th Jan 2018, 10:14 AM
Abhishek Bansal
Abhishek Bansal - avatar
2 Respostas
+ 1
Getter method is used to return the variable's value. Setter method is used to set the variable's value.
9th Jan 2018, 10:17 AM
Abhishek Bansal
Abhishek Bansal - avatar
+ 1
Usually because encapsulation meme. Sometimes because it allows you to do fancy stuff when changing values.
9th Jan 2018, 10:37 AM
BlazingMagpie
BlazingMagpie - avatar