3.6. Operators

Binary operators are used to perform tasks with two operands. There are operators for arithmetic, incrementing and decrementing, logical operations, and bitwise operations.

3.6.1. Arithmetic Operators

These are as you would expect: +, –, /, and * for addition, subtraction, division, and multiplication. The remainder of an integer operation is given by mod (%).

Note

Instead of writing out MOD as you might in ColdFusion (for example, 10 MOD 3), Java uses the % sign. So 10 % 3 is 1.

It is common to have to modify an existing value. Java offers a concise way to use arithmetic operators. Instead of writing

x = x + 1; 

you can write

x += 1; 

These are equivalent operations. You can also perform other mathematical operations (–, *, ...

Get Java™ for ColdFusion® Developers 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.