Skip to content

Operator

Operators in Java

Operator in Java is a symbol that is used to perform operations.
There are many types of operators in Java which are given below: Here is a brief introduction to Java operators:

  1. Arithmetic Operators:
    Perform basic mathematical operations like addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).

  2. Relational Operators:
    Compare two values, resulting in a boolean (true or false). Examples include ==, !=, >, <, >=, and <=.

  3. Logical Operators:
    Used to combine multiple boolean expressions. Common operators are && (AND), || (OR), and ! (NOT).

  4. Bitwise Operators:
    Operate on bits of integers. Includes & (AND), | (OR), ^ (XOR), ~ (NOT), << (left shift), >> (right shift).

  5. Assignment Operators:
    Assign values to variables. The basic operator is =, and combined operators include +=, -=, *=, /=, etc.

  6. Unary Operators:
    Operate on a single operand. Includes increment (++), decrement (--), positive (+), and negative (-).

  7. Ternary Operator:
    A shorthand for if-else condition. Syntax: condition ? expr1 : expr2.

  8. Instanceof Operator:
    Tests whether an object is an instance of a specific class or subclass. Syntax: obj instanceof ClassName.

Short Video Lecture

(Video here)

VisualCodeChat Tutoring (Exercise: Integer Division and Remainder)

Interact and Learn with VisualCodeChat!

After-class Exercises

(Exercises here)