This question about why constants in Java are uppercase by convention made me try to think of counter examples.
I can think of at least one (Double.NaN
). Are there others?
Of course, public final static PrintStream out
(in java.lang.System.out
). But it's a very good exception, because System.OUT.println
is just ugly.
Also, most of the time loggers are initialized as follows:
private static final Logger logger = Logger.getLogger(MyClass.class);
However, in both cases these are not constants in the true sense of the term. So perhaps we can make a distinction:
Fields that are static
because they need a static access, and final
because they should not be re-assigned at runtime, are not necessarily constants.
There are lots of serialVersionUID
!
Others in ResultSetMetaData
like columnNoNulls
, columnNullable
...DatabaseMetaData
and ICC_Profile
have lots of mixed case constants.
Here is a list with most, if not all, JavaSE constants: Constant Field Values
Color constants like black, red, green etc from java.awt.Color class.
It should be noted that java.awt.Color also provides the uppercase alternatives (e.g. BLACK, RED, GREEN etc) of these constants.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With