Operators in Java

Operators are special characters or symbols used to perform operations on operands, which can be variables, literals, or expressions.


Classification of Operators Based on Number of Operands

  1. Unary Operator: Operates on a single operand. Examples: !, ++, --.
  2. Binary Operator: Operates on two operands. Examples: +, -, *, /, %, ==, &&.
  3. Ternary Operator: Operates on three operands. Example: ? :.

Classification Based on the Operation They Perform

  1. Arithmetic Operators
  2. Assignment Operator
  3. Compound Assignment Operators
  4. Logical Operators
  5. Relational Operators
  6. Increment/Decrement Operators
  7. Conditional (Ternary) Operator
  8. Bitwise Operators

1. Arithmetic Operators

Arithmetic operators are used to perform basic mathematical operations on both primitive and non-primitive data types.