15.28. Constant Expressions
ConstantExpression: Expression
A compile-time constant expression is an expression denoting a value of primitive type or a String
that does not complete abruptly and is composed using only the following:
• Literals of primitive type and literals of type String
(§3.10.1, §3.10.2, §3.10.3, §3.10.4, §3.10.5)
• Casts to primitive types and casts to type String
(§15.16)
• The unary operators +
, -
, ~
, and !
(but not ++
or --
) (§15.15.3, §15.15.4, §15.15.5, §15.15.6)
• The multiplicative operators *
, /
, and %
(§15.17)
• The additive operators +
and -
(§15.18)
• The shift operators <<
, >>
, and >>>
(§15.19)
• The relational operators <
, <=
, >
, and >=
(but not instanceof
) (§15.20)
• The equality operators ==
and !=
(§15.21 ...
Get The Java® Language Specification, Java SE 7 Edition, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.