0
why getter setter method is so important ?
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();
+ 1
i want to get experience thats why i asked u
0
No.i think