What are Operators in Java - Types of Operators in Java ( With Examples )

An operator in Java is a special symbol that performs an operation on one, two, or three operands and produces a result. Operators are the building blocks of nearly every expression you write, from simple math to complex conditions.

Types of Operators in Java

Java organizes operators into several categories based on the kind of operation they perform.

1. Arithmetic Operators

Used to perform basic mathematical operations like addition, subtraction, multiplication, division, and modulus.

int sum = 10 + 5;
int mod = 10 % 3; // 1

2. Relational (Comparison) Operators

Used to compare two values and return a boolean result, such as ==, !=, >, and <.

3. Logical Operators

Used to combine multiple boolean expressions, including && (AND), || (OR), and ! (NOT).

4. Assignment Operators

Used to assign values to variables, including the simple = as well as shorthand operators like +=, -=, and *=.

5. Unary Operators

Operate on a single operand, such as increment (++), decrement (--), unary plus, and unary minus.

6. Bitwise Operators

Work directly on the individual bits of integer values, including &, |, ^, ~, <<, and >>.

7. Ternary Operator

Java's only three-operand operator, written as condition ? valueIfTrue : valueIfFalse, offers a compact alternative to a simple if...else.

Operator Precedence

When multiple operators appear in one expression, Java evaluates them according to a defined precedence order — for example, multiplication and division happen before addition and subtraction, unless parentheses say otherwise.

  • Arithmetic — perform mathematical calculations
  • Relational — compare two values
  • Logical — combine boolean conditions
  • Assignment — assign or update variable values
  • Unary — act on a single operand
  • Bitwise — manipulate individual bits
  • Ternary — a shorthand conditional expression
Understanding operator categories and precedence is essential — most beginner bugs come from misjudging the order in which an expression actually gets evaluated.

Master Java with Uncodemy

Hands-on training, live projects, and placement support in our Java Programming Course.

Explore the Course