I know that in Java, it is common practice to use "get" as a prefix to an accessor method. I was wondering what the reason for this is. Is it purely to be able to predict what it is returning?
To clarify: In some java classes (eg String
) a variable like length can be accessed by calling "length()" rather than "size()
". Why are these methods written like this, but others like "getSomeVariable()
"?
Thank you for your time.
Edit: Good to see I'm not alone about the confusion & such about the size and length variables