Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
Getters and setters are inbuilt methods of java ?
we have to define getrers and setters for our program . we can even achive the same with any other self defined method , then what is the need of getters and setters?
5 Answers
+ 6
youre welcome :)
+ 4
they are used for private variables and you shouldnt really use a classe's variable directly from outside itself
+ 4
well yes you can, but for convention, you shouldnt ;)
just call what you need after its been set or accessed
+ 2
Ok,
thanks:)
+ 1
then in there place I can use any other method?