Elana Abelev wrote:
So... It seems they can, IF these static fields are marked final. (Couldn't get a static final method declaration to compile, so I guess this quirk only applies to fields).
I found a couple threads on these boards that discuss this, but none that address what the book states (that I found, at least). I think it's an important fact one should be aware of when studying for the exam. Why has the book omitted it?
It is actually more than just final. It has to fulfill all the requirements of a compile time constant.
... and ... when it is a compile time constant, then the field is a compiler constant. Interestingly, the field doesn't actually exist at runtime, as the compiler will, as optimization, insert the value into the generated code directly.
Henry