Operators in Java

Operators perform data manipulation on one more input or more input variable(called operands).
⦁ Arithmetic operators
⦁ Assignment operators
⦁ Bitwise Operators
⦁ Logical Operators
⦁ Relational Operators ⦁ Special Operators


1.Arithmetic operators:
this set includes the basic arithmetic operators to perform basic arithmetic operations like (1).addition(+), (2).subtraction(-), (3)multiplication(*), (4)division(/).

2.Assignment Operators:
the assignment Operators assign value to a variable. the following assignment operators are:

Assignment Operators

3. Bitwise operators: These operators work bitwise on data. They perform different operations on bits of data like AND, OR, EXOR and NOT.

Bitwise Operator in Java
Bitwise Operator in Java

4.Logical Operators: A logical operator returns a boolean result based on the boolean result of one or more expressions. They may also called Boolean operators.

logical Operator
Logical Operator

5.Relational Operators:
Relational Operators are usually binary operators. they check the relationship between two operators and that are usually numbers or at least can be represented as numbers. they return boolean value.

Relational Operators

6.Special Operators :

Java support some special operators of interest such as instanceof operator and member selection operator(.).

Instanceof Operators

The instanceof is an object reference operator and returns true if the object on the left-hand side is an instance of the class given on the right-hand side. They allow us to determine whether the object belongs to a particular class or not.

Example:

salary instanceof  person

This can be only true if the object’s salary belongs to the class person Otherwise it is false.

Dot Operator

The dot operator(.) is used to access the instance variables and methods of class objects.

Example:

person.id    //reference to the variable id
person.salary() //reference to the method salary 
Translate »