Java Supports a rich set of operators. We have totally 8 types of operators in java. An operators is a symbol that tells the computer to perform certain mathematical or logical manipulations. Operators are used in programs to manipulate data and variables. They usually form a part of mathematical or logical expressions. Java operators can be classified into a number of related categories as shown below

- Arithmetic Operators
- Relational Operators
- Logical operators
- Assignment operators
- Increment and Decrement operators
- conditional operator
- Bit wise operators
- Special operators

Arithmetic operators are used to construct mathematical expressions as in algebra. Java supports all the basic arithmetic operators.

**Operator**

**Meaning**
+ Addition or Unary plus

- subtraction or unary minus

* Multiplication

/ Division

% Modula division ( Remainder)

- subtraction or unary minus

* Multiplication

/ Division

% Modula division ( Remainder)

#### Relational operators

We often compare two quantities, and depending on their reaction, take certain decisions. For example, we may compare the age of two persons, or the price of two items, and so on. These comparisons can be done with the help of relational operators. Java supports six relational operators

**Operator**

**Meaning**
< is less than

< = is less than or equal to

> is greater than

>= is greater than or equal to

= = is equal

!= is not equal

< = is less than or equal to

> is greater than

>= is greater than or equal to

= = is equal

!= is not equal

#### Logical Operators

In addition to the relational operators, java has three logical operators

**Operator**

**Meaning**
&& Logical AND

|| Logical OR

! Logical NOT

Variable Operator = expression;

expression1?expression2:expression3

|| Logical OR

! Logical NOT

#### Assignment operators

Assignment operators are used to assign the value of an expression to a variable. Java has a set of "short hand" assignment operators which are used in the formVariable Operator = expression;

#### Increment and decrement operators

Java has two very useful operators not generally found in many languages. These are the increment and decrement operators ++ and -- .#### Conditional Or Ternary Operator

The character pair ? : is a ternary operator available in java. This operator is used to construct conditional expression of the formexpression1?expression2:expression3

## 0 comments :

## Post a Comment

Note: only a member of this blog may post a comment.