Expressions in Java
Expressions in Java are very similar to expressions in C or C++:
- 3.141592654 is an expression of type double.
It is also a literal.
- (i>64) && (i<73) is an expression of type boolean.
- (k>128) ? 1 : 0 is an expression of type integer.
- i=1 is an integer expression. (It is also a statement.)
- i=1, j=2 is only allowed as an expression in tne initialization
or continuation of a for loop.
- 'a', '\n' and '\u1234' are character expressions.
They are also literals.
- object.method(params) is a method call.
- Different integral types can be mixed in an expression.
- Integral types, floats and doubles can be mixed in an expression.