+ 4

Getter-setter or Constructors ??

we can use getter-setter or constructors to access private data of class..which one is better ??

6th Mar 2018, 4:42 AM
Shruti Singh
Shruti Singh - avatar
6 Answers
+ 3
hey
13th Apr 2018, 6:47 AM
Rohith M
Rohith M - avatar
+ 2
Constructor to enter some stuff during object creation. Getter to get private data. Setter to change or set data to new value.
6th Mar 2018, 5:42 AM
Sad
Sad - avatar
+ 1
😁 @Shruti Singh you will need all of them in different situations.
6th Mar 2018, 5:47 AM
Sad
Sad - avatar
8th Mar 2018, 8:28 AM
Eugene Nefedov
Eugene Nefedov - avatar
0
The reason for getter and setting is to acess private class and transfer data from one class to another
25th Mar 2018, 9:35 AM
GeneralZod
GeneralZod - avatar
0
Shirut what language
25th Mar 2018, 9:35 AM
GeneralZod
GeneralZod - avatar