Expressions

There's a lengthy chapter in the Java Language Specification on expressions, covering many cases that would be interesting only to language lawyers. What it boils down to is that an expression is any of the alternatives shown in Table 7-2.

Table 7-2. Expressions in Java

Expression

Example of expression

A literal

245

this object reference

this

A field access

now.hh

A method call

now.fillTimes()

An object creation

new Timestamp( 12, 0, 0 )

An array creation

new int[27]

An array access

myArray[i][j]

Any expression connected by operators

now.mins / 60

Any expression in parens

( now.millisecs * 1000 )

You evaluate an expression, to get a result that will be:

  • A variable (as in ...

Get Just Java™ 2 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.