why getter setter method is so important ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why getter setter method is so important ?

28th May 2017, 5:18 AM
Somnath Ghosh
Somnath Ghosh - avatar
3 Answers
+ 1
So you can access and modify a private member of a class. It's only important if you will need to use it. Ex/ class Me{ private String name; Me(String newName){ this.name = newName; } } How can I possibly access name from another class? Well, with an accessor, since the method would be public. So, maybe I can do: Me aMe = new Me("iam"); String myName = aMe.getName();
28th May 2017, 5:25 AM
Rrestoring faith
Rrestoring faith - avatar
+ 1
i want to get experience thats why i asked u
30th May 2017, 5:19 PM
Somnath Ghosh
Somnath Ghosh - avatar
0
No.i think
28th May 2017, 5:35 AM
Somnath Ghosh
Somnath Ghosh - avatar