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

Answer by Andrew Skirrow for Java setter and getter?

$
0
0

Very simple Example:

Version 1 of class could have getter like this.

public int getTotal() {   return total_;}

Version 2 could do this

public int getTotal() {  return a + b;}

We've changed how the class is implemented, but clients of the class don't need to change as well, because the data is hidden behind a getter.


Viewing all articles
Browse latest Browse all 14

Trending Articles



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