can anyone explain getter and setter in detail..i am not able to understand plzz..?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

can anyone explain getter and setter in detail..i am not able to understand plzz..??

3rd Jul 2016, 8:46 AM
Chaitanya Pandit
Chaitanya Pandit - avatar
5 Answers
+ 1
getter is the term used for functions which return some value. setter is used to set values to variables. in order to prevent unauthorized modification to values of variables, we restrict this access in these functions. this thing comes under encapsulation concept. syntax : public int getAttribute(); public void setAttribute(int data);
3rd Jul 2016, 10:06 AM
Mrunal Selokar
Mrunal Selokar - avatar
0
Yaaa
3rd Jul 2016, 8:49 AM
shubhu
0
Itss a jst common
3rd Jul 2016, 8:50 AM
shubhu
0
Like getter so u would b able to get any valu to d prgm whereas setter for set a value to the variable which we has apply
3rd Jul 2016, 8:51 AM
shubhu
0
Consider the example of a Money class that has a getValue() method on it that returns the "value" in dollars.
3rd Jul 2016, 10:27 AM
shubhu