there is a rule which says:
Names representing constants (final variables) must be all uppercase
using underscore to separate words
(taken from http://geosoft.no/development/javastyle.html)
that works fine for primitive types like int or strings:
private static final int MAX_COUNT = 10;
But what’s about non primitive types? In most cases I’ve seen the following:
private static final Logger log = Logger.getLogger(MyClass.class);
or in singletons, where instance variable is not in upper case.
The question is what is the right way to declare those types of variables (like log and instance)?
That’s still a constant. See the JLS for more information regarding the naming convention for constants. But in reality, it’s all a matter of preference.