> On 16 Mrz., 07:03, Roedy Green <see_webs...@mindprod.com.invalid>
> wrote:
[quoted text clipped - 4 lines]
>
> Yap. So any final local variables are mixedCased...
That was never in question, since the convention of ALL_UPPER_CASE applies
only to static variables.
>> I sometimes violate
>> the convention for something that is a static final, but is not a
>> constant in the sense of a configuration int or String, e.g. a HashMap
>> that is allocated once and for all statically.
>
> I like that! Same opinion here. I'll do it that way, too...
For that one I'd use camel case, since a HashMap exists only to be modified.
The coding conventions
<http://java.sun.com/docs/codeconv/>
specifically call for *class constants* to be spelled in all upper case.
<http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html#367>
Note that the JLS says "may conventionally be", not "should be" nor "must be"
for using all upper case on final class variables. Furthermore, the section
in the JLS, § 6.8.6, is entitled "Constant Names", not "Final Variable Names".
The "correct" convention is to spell static constant names with all upper-case
letters, other variables (final or not) with mixed case. People do ("may
conventionally") shade the rule to use all upper case to name final statics
where they are used immutably even if the object isn't a constant.
<http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.12.4>
> We call a variable, of primitive type or type String, that is final and
> initialized with a compile-time constant expression (§15.28) a constant variable.
<http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.28>
When enums were added, the convention was extended to enum constants, as
illustrated in the JLS § 8.9.

Signature
Lew
Roedy Green - 17 Mar 2008 11:04 GMT
>For that one I'd use camel case, since a HashMap exists only to be modified.
The reference is a constant final, but the HashMap itself is usually
quite mutable. Further the reference is not in principle final. It
just happens to be for now. True constants are not just unchanged for
now, they are unchanging in principle.
For those reasons, like Lew, I don't feel guilty using camel case for
static final HashMap hashMap...

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com