Q:

When do I create a getter method without "get" in its name?

The following question has been bothering me for a long time and I couldn't find any information on the naming conventions.
There is methods like:
java.util.Collection.size();

This method is actually a getter for the size of a Collection, yet it doesn't begin with "get" unlike regular getter methods.
So what are the naming conventions for these types of methods?

A:

Collection.size() is not a typical getter as it is not a simple return of a field- it is the size of a collection, for this reason you don't have setSize(), since this is not a field you set- this is a 'calculated' value.
You can think of it this way- getter and setters usually go together, in order to encapsulate a field- if you can't do setX(), than it's not a typical getter/setter.
But this is only a matter of convention, there are people who believe in always using it without the words get or set. 

A:

There is no real 'rule' for this. Sometimes classes give you values by functions like size() or length(). Others will give it back by get...().
From my experience, lengths are usually got from size() or length() (like arrays), for other variables it goes by get...() (like in android - getHeight()).  
You can say it because getters go with setters, if there is no setter to size - there wouldn't be a getter.

