Java Basic - Basic Operators

1 minute read

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

  • Arithmetic Operators
  • Relational Operators
  • Bitwise Operators
  • Logical Operators
  • Assignment Operators
  • Misc Operators

Tables

The Arithmetic Operators

  • + (addition)
  • - (subtraction)
  • * (multiplication)
  • / (devision)
  • % (modulus)
  • ++ (increment)
  • -- (decrement)

The Relational Operators

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

The Bitwise Operators

  • & (bitwise and)
  • | (bitwise or)
  • ^ (bitwise XOR)
  • ~ (bitwise compliment)
  • << (left shift)
  • >> (right shift)
  • >>> (zero fill right shift)

The Logical Operators

  • && (logical and)
  • || (logical or)
  • ! (logical not)

The Assignment Operators

read more

The Misc Operators

Conditional Operator (?:)

variable x = (expression) ? value if true : value if false

instance of Operator

(Object reference variable) instanceof (class/interface type)

Precedence of Java Operators

read more

Leave a Comment