0

why there is no this in get method encapsulation

26th Jul 2018, 7:37 PM
Omar Essam
Omar Essam - avatar
2 Respuestas
+ 1
WHAT???
26th Jul 2018, 8:18 PM
KrOW
KrOW - avatar
0
Because there's no ambiguity. When you use a setter you often use the same name for the parameter as the field. Here you MUST use this.fieldName = fieldName to clarify. With the getter you could return this.field but it is the same as returning 'field'
26th Jul 2018, 8:34 PM
Dan Walker
Dan Walker - avatar