๐ŸŽ‰ Special Offer !    Code: GET300OFF    Flat โ‚น300 OFF on every Java Course
Grab Deal ๐Ÿš€

Operators in Java  


Introduction

  • Operators are the special symbols used to perform an operation on one or more operands.
  • For example :
    int no1=10, no2=20;
    int res = no1 + no2; // '+' & '=' are operators and no1 and no2 are operands 

Below is the list of all operators present in Java :-

Category Description Examples Programs
Arithmetic Operators Perform basic mathematical operations.
  • + (Addition operator)
  • - (Subtraction operator)
  • * (Multiplication operator)
  • / (Division operator)
  • % (Modulus operator)
Arithmetic Operators Explanation & Program
Assignment Operators Assign values to variables.
  • = (Assignment operator)
  • += (Addition assignment operator)
  • -=(Subtraction assignment operator)
  • *= (Multiplication assignment operator)
  • /= (Division assignment operator)
  • %= (Modulus assignment operator)
Assignment Operators Explanation & Program
Relational Operators Compare two values and return a boolean result.
  • == (Equal to operator)
  • != (Not equal to operator)
  • < (Less than operator)
  • > (Greater than operator)
  • <= (Less than or equal to operator)
  • >= (Greater than or equal to operator)
Relational Operators Explanation & Program
Logical Operators Perform logical operations on boolean expressions.
  • && (Logical AND operator)
  • || (Logical OR operator)
  • ! (Logical NOT operator)
Logical Operators Explanation & Program
Ternary Operator A shorthand for an if-else condition.
  • condition ? value1 : value2
    (Ternary operator)
Ternary Operator Explanation & Program
Unary Operators Operate on a single operand.
  • + (Unary plus operator)
  • - (Unary minus operator)
  • ++ (Increment operator)
  • -- (Decrement operator)
  • ! (Logical NOT operator)
Unary Operators Explanation & Program
Bitwise Operators Operate on binary representations of integers.
  • & (Bitwise AND operator)
  • | (Bitwise OR operator)
  • ^ (Bitwise XOR operator)
  • ~ (Bitwise NOT operator)
Bitwise Operators Explanation & Program
Shift Operators Shift the bits of a number to the left or right.
  • << (Left shift operator)
  • >> (Right shift operator)
  • >>> (Unsigned right shift operator)
Shift Operators Explanation & Program
Instanceof Operator Checks whether an object is an instance of a specific class or subclass.
  • object instanceof ClassName
    (Instance check operator)
Instanceof Operators Explanation & Program