Arithmetic Operators

Basic math operations can be applied to int, double, and float data types:

  • + addition
  • - subtraction
  • * multiplication
  • / division
  • % modulo (yields the remainder)

These operations are not supported for other data types.


Comparison Operators

Comparison operators can be used to compare two values:

  • > greater than
  • < less than
  • >= greater than or equal to
  • <= less than or equal to
  • == equal to
  • != not equal to

They are supported for primitive data types and the result of a comparison is a boolean value true or false:


Bitwise Operators

Bitwise operators are used to manipulate individual bits of a number.

  • & Bitwise AND
  • | Bitwise OR
  • ^ Bitwise XOR
  • ~ Bitwise complement
  • << Signed right shift operator
  • >> Signed left shift operator
  • >>> Unsigned right shift operator
  • <<< Unsigned left shift operator

They can only be operated on data of int, char, byte, long, and short.

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn Java on Codecademy