ConstantExpression:
Expression
A compile-time constant expression is an expression denoting a value of primitive type or a String that is composed using only the following:
String
String
+, -, ~, and ! (but not ++ or --)
*, /, and %
+ and -
<<, >>, and >>>
<, <=, >, and >= (but not instanceof)
== and !=
&, ^, and |
&& and the conditional-or operator ||
? :
final variables whose initializers are constant expressions
. Identifier that refer to final variables whose initializers are constant expressions
Compile-time constant expressions are used in case labels in switch statements
(§14.9) and have a special significance for assignment conversion (§5.2).
Examples of constant expressions:
true (short)(1*2*3*4*5*6) Integer.MAX_VALUE / 2 2.0 * Math.PI "The integer " + Long.MAX_VALUE + " is mighty big."
. . . when faces of the throng turned toward him and ambiguous eyes stared
into his, he assumed the most romantic of expressions . . .
--F. Scott Fitzgerald, This Side of Paradise (1920)