Quantcast
Channel: Java setter and getter? - Stack Overflow
Viewing all articles
Browse latest Browse all 14

Answer by Andreas Dolk for Java setter and getter?

$
0
0

The class fields are hidden, if we declare them private. No doubt (we ignore nasty reflection tricks). If we want to make the values accessible, we provide access methods (getter/setter for example).

But there is no requirement to provide getters and setters for all fields or to name them according to fields (in general).

The class internals (the fields) are perfectly hidden.


Viewing all articles
Browse latest Browse all 14

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>