The Arithmetic Operators

The Arithmetic Operators

  • The Java programming language provides operators that perform addition, subtraction, multiplication, and division. There's a good chance you'll recognize them by their counterparts in basic mathematics. The only symbol that might look new to you is "%", which divides one operand by another and returns the remainder as its result.
  • The + operator can also be used for concatenating (joining) two strings together, as shown in the following ConcatDemo program:.
  • You can also combine the arithmetic operators with the simple assignment operator to create compound assignments. For example, x+=1; and x=x+1; both increment the value of x by 1.

Related concepts

The Arithmetic Operators — Structure map

Clickable & Draggable!

The Arithmetic Operators — Related pages: