O'Reilly logo

The Java® Language Specification, Java SE 7 Edition, Fourth Edition by Alex Buckley, Gilad Bracha, Guy Steele, Bill Joy, James Gosling

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 String3.10.1, §3.10.2, §3.10.3, §3.10.4, §3.10.5)

• Casts to primitive types and casts to type String15.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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required