Top
Previous Next
The Java Language CS 161 - Java

Expressions

Definition: An expression is a series of variables, operators, and method calls (constructed according to the syntax of the language) that evaluates to a single value.
from: The Java Tutorial, Campione & Walrath, 1998

Example

// Examples of declaration and expression evaluation

int i;
 ...
i = 1;

int j;
 ...
j = i + 1;

CreditCard card = myCard.dependentsCard();

float whatIOwe = whatIOwedLastMonth +
                 visaCard.balance() +
                 mastercardCard.balance() +
                 discoverCard.balance();
The code is always of the form:
destination = expression_to_be_evaluated ;

First time programmers often write
expression to be evaluated = destination ;
It doesn't work that way.

Top
Previous Next
jwd