Operators in java

0
Share

What is operators ?

Operator is a symbol which operates the operand mathematically and logically.

According to the involvement of operand, operator are classified as 3 types :-

  • Unary operator (Those operators, operates only a single operand at a time known as unary operator. Example – ++, –, !, ~ etc).
  • Binary operator (Those operators, operates only a two operand at a time known as Binary operator. Example – +, -, ), /, % etc.)
  • Trinary operator (Those operators, operates only a three operand at a time known as Trinary operator. Example – ? )

Arithmetic Operator

Those operators are involved with the arithmetic operation like – addition, subtraction, multiplication, division & modulation known as arithmetic operators.

Addition+
Substraction
Multiplication*
Division/
Modulus%
Arithmetic Operators

Relational Operators

  • Those operator are used for comparison of the operand known as relational Operators.
  • Each & every relational operator have return either True or false as output.
  • If the statement is satisfied it return as a True otherwise return as a false.
<Smaller than
>Greater than
==Double equal
<=smaller than equal
>=Greater than equal
!=Not equal
Relational Operators

Logical Operatrors

Those operator logically operate the operand known as logical operator. It returns either True or false as a output.

&&Logical AND
||Logical OR
!Logical NOT
Logical Operators

Conditional Operators

  • Those operator conditionally operate the operand known as conditional operator.
  • The syntax of conditional operator is- (Condition)? Statement1:Statement2;
  • In case of conditional operator the statement after ? will execute and statement (:) will remain silent otherwise vice versa.
  • Example-
x=5;
y=7;
Big=(x>y)?x:y;

output= 7

Bitwise operator

 Bitwise operators are used to performing manipulation of individual bits of a number. In java there are different types of bitwise operator available such as –

  • Bitwise AND – & (In this case operator of both bits are 1 then the result will be 1 otherwise result will be 0.)
  • Bitwise OR – / (In this case operator of both bits are 0 then the result will be 0 otherwise result will be 1.)
  • Bitwise XOR – ^ (In this case operator of both bits are same then the result will be 0 otherwise result will be 1.)
  • Bitwise Right-shift – >> (In this case the given number of bit will be eliminated from right & sum number of 0 will be added in the left.)
  • Bitwise Left-shift -<< (In this case only the given number of 0 will add in the right without any elimination from left.)

Increment & Decrement operators

The increment & decrement operator are used to increase and decrease the operand by one .

Special Operators

In java there are many operator and symbol which are used for some special purpose that operators known as special operators.

Example – comma , semi colon, [ ], { } etc.

Identifiers

It is nothing but a naming the variable, comma, interphase & methods. It is used for accessing the variable

Read more post

  • What are the List of CSS3 New Features ?
    CSS3 is the latest version of the normal CSS . CSS3 adds several new styling features and improvements to enhance the web presentation capabilities. Text Effect in...
  • CSS Basic Property
    What is CSS ? CSS stands for Cascading Style Sheets. CSS basically used in designing the web tags & pages. CSS is the most popular used...
  • Java Program to swap two number use 3rd variable
    In this program, you’ll learn to Program to swap 2 number with 3rd variable in Java. After write the code, the final output is displayed on...
  • Java program to multiply two floating point number
    In this program, you’ll learn to Program to multiply two floating point number in Java. After write the code, the final output is displayed on the...
  • Java Program to find the ASCII value of a character
    In this program, you’ll learn to Program to find the ASCII value of a character in Java. After write the code, the final output is displayed...
  • Java Program to calculate quotient & reminder
    In this program, you’ll learn to Given Number is even or odd in Java. After write the code, the final output is displayed on the screen....
%d bloggers like this: