I am develoing a Web Application, in that there is a utility method named getData()
which I made it as a static.
Until now its fine, but this static method named getData()
needs some data from setters and getters.
So now my question is can we make setter/getters as static?
Yes, it's possible and you can do that. There are two kinds of getters and setter functions: static.
Usually you want setters/getters to be public, because that's what they are for: giving access to data, you don't want to give others direct access to because you don't want them to mess with your implementation dependent details - that's what encapsulation is about.
The reason for declaring the getters and setters private is to make the corresponding part of the object's abstract state (i.e. the values) private. That's largely independent of the decision to use getters and setters or not to hide the implementation types, prevent direct access, etc.
if your Properties are static
then Getters and setters
will also be static
.. its all depends on You..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With