Introduction to expressions
An expression is a mathematical term,
describing a part of a program statement that evaluates to a single value. Of course, in
Java the type of value can be an object, an array or a primitive type.
Expressions are composed of operators and
operands.
Expressions may be simple, such as:
7
which simply evaluates to itself, i.e. the
integer constant 7.
Expressions can be complex, such as:
netTax = (float)
35.75 * ( grossEarnings + operatingProfit( 1999 ) )
which involves:
- floating point constants — 37.75
- conversion between types — casting using (float)
- variables — grossEarnings
- message passing (with arguments) and replies — operatingProfit( 1999 )
Each of the Java types has associated with it
a set of operators (such as '+', '/', '&&') that can be arranged with operands to
create expressions to be evaluated.
Back
to top
. 
RITSEC - Global Campus
Copyright ?1999 RITSEC- Middlesex University. All rights reserved.
webmaster@globalcampus.com.eg
|