Arithmetic Operators in Java with Examples

In this article, we'll learn Arithmetic operators in Java programming language, their syntax and how to use them with examples.

The Arithmetic Operators

Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra.

The following table lists the arithmetic operators:

The operands of the arithmetic operators must be of a numeric type. You cannot use them on boolean types, but you can use them on char types, since the char type in Java is, essentially, a subset of an int.

The Basic Arithmetic Operators

The basic arithmetic operations — addition, subtraction, multiplication, and division — all behave as you would expect for all numeric types. The unary minus operator negates its single operand.

The following simple example program demonstrates the arithmetic operators. It also illustrates the difference between floating-point division and integer division.