Operators in Java

Java offers many operators that can be used to perform tasks on variables. These operators can be divided into the following categories:

  1. Arithmetic Operators: These operators are used to perform mathematical operations on variables such as addition (+), subtraction (-), multiplication (*), division (/), and modulo (%).
  2. Assignment Operators: These operators are used to assign a value to a variable (=, +=, -=, *=, and /=).
  3. Relational Operators: These operators are used to compare two variables to create a Boolean expression and determine if the statement is true or false (<, >, <=, >=, ==, and !=).
  4. Logical Operators: These operators are used to evaluate boolean expressions and return either a true or false result (&&, ||, !).
  5. Increment/Decrement Operators: These operators are used to add or subtract one from a numeric value (++, –).
  6. Bitwise Operators: These operators are used to manipulate the binary values of a variable (~, &, |, ^).
  7. Miscellaneous Operators: These operators are used to perform miscellaneous operations such as type casting, instanceof operator, conditional operator, and others.