Operators in JAVA

Java provides operators in the following categories:

  • Arithmetic Operators

  • Bitwise Operators

  • Relational Operator

  • Logical Operator

JAVA also defines some additional operators that handle some special situations.

Arithmetic Operators

Arithmetic operators are used in mathematical operations and similarly in algebra. These are the Arithmetic Operators:

arithmatic operator

The operands of the arithmetic operators must be of type numeric. You cannot use them in boolean types but can use them in char types.

Bitwise Operators

JAVA programming language also provides operators that perform bitwise and bit shift operations on integral types. The operators discussed in this section are less commonly used. Therefore, their coverage is brief. The intent is to simply make you aware that these operators exist.

Bitwise Operators in Java.PNG

Relational Operator

Relational Operators determine if one operand is greater than, less than, equal to, or not equal to another operand. The majority of these operators will probably look familiar to you. Keep in mind that you must use “==”, not “=”, when testing if two primitive values are equal.

relational operator

Logical Operator

Logical operators are mainly used to control program flow. Usually, you will find them as a part of an if, a while, or some other control statement.

Logical Operators

3 thoughts on “Operators in JAVA

Add yours

    1. Hello 🙂 ,

      ” = ” is assignment operator used to assign value to any datatype
      for Example:
      int a; // here a is integer variable
      a = 5; // so here using ” = ” 5 is assigned to variable a


      Now ” == ” is used to compare two values whether they are equal or not
      for Example:
      int a=5, b=6;
      if ( a == b ) // here we can not use ” = “, doing this it will assign value of b to a
      System.out.println(“a and b are equal”);
      System.out.println(“a and b are not equal”);

      Output : a and b are not equal


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Powered by WordPress.com.

Up ↑

%d bloggers like this: