| Operator |
Description |
Examples |
| = |
Assignment operator. |
x = 0; |
| ?: |
Ternary conditional operator. If the first operand evaluates to
true, returns the second operand, otherwise returns the third operand. |
str == null ? 0 : str.length(); |
| || |
Binary boolean 'or' operator. Returns true if one of the operands
evaluates to true. This is a short circuit operator. If the first
operand evaluates to true, the second is not evaluated. |
a || b |
| && |
Binary boolean 'and' operator. Returns true if both operands evaluate
to true. This is a short circuit operator. If the first operand evaluates
to false, the second is not evaluated. |
a && b |
==
!= >>
=< <= |
Binary relational operators. The equality '==' and nonequality operators
may be applied to any types. The other operators are useful for numeric
types. |
a == "abc"
n != 0
g > 2.3 |
| + |
Binary addition operator. Returns the sum of the operands for numeric
types. If one of the operands is a string, the other operand is converted
to a string and the concatenation of the two strings is returned. |
98.0 + x "abc"
+ n98 + "th" |
| * |
Binary multiplication operator. Returns the product of the operands. |
8 * 98
.03 * 8 |
| +- |
Unary plus and minus. |
+9.0
-988 |
| ! |
Boolean negation. Returns true if the operand evaluates to false,
otherwise returns true. |
!(a && b)
!flag |
| (type) |
Type cast operator as in Java. Used to convert between Java types. |
str = (String) list[0];
((Number) obj).intValue();
model.acceptOrder((Order) obj); |