Sponsered Links
Categories
Sponsered Links

Operator in java

 

An Operator is a symbol that tells to computer to perform  certain action mathematical or logical manipulation. Operator are used in programs to manipulate data and variable. Operator in java  eight types

  1. Arithmetic Operators
  2. Relational Operators
  3. Logical Operators
  4. Assignment Operator
  5. Increment and decrement  Operators
  6. Bitwise Operators
  7. Special Operators 

1. Arithmetic Operator  Arithmetic Operators are used in Mathematical expressions in a same  way that they are used in algebra.

Operator Result

+                 Addition

-                 Subtraction

*                 Multiplication

/                 Division

%                 Modulus

  2. Relational Operator Relational Operator  determine the relationship that operand has to other. when arithmetic expression are used on either side  of a relational operator , the arithmetic expression  will be  evaluated  first  and then result  compared.   arithmetic operators have a higher priority over relational operator.

    Operator                    Result

     <                    Less than  

     <=                    Less than or equal to            

      >                    Greater than    

      >=                    Greater than or equal to         

      ==                    Equal to

     !=                     Not equal to      

 3. Logical Operator  

          Operator                         Result   

            &                                     Logical AND

           &&                           Short_ circuit AND

              |                                    Logical   OR

             ||                                     Short_ circuit OR

            ?:                            Ternary  if-then-else

            !                                     Logical  unary NOT

 4. Assignment Operator  Assignment Operators are used to assign to the value of an expression to a variable.

syntax:- int aa = 100;

5. Increment and decrement Operator .

                Operator                  Result

                  ++                                 Increment

                  --                                 Decrement

Note - Increment Operator also divided into two type.

  Pre      Increment    //  ++aa;

  Post    Increment       //   aa++;             

 Decrement Operator also divided into two type.

pre Decrement Operator    //  --aa;

Post Decrement Operator    //  aa--;

6. Bitwise Operator  These Operator used for testing  the bit  or shifting  to right or left.

                Operator                     Result

                   ~                     Bitwise unary NOT

                 &                     Bitwise AND

                 -                     Bitwise  NOT

                ^                     Bitwise exclusive OR

               <<                     Shift   left

               >>                     Shift   Right

               >>>  

7. Special Operator Java support two special operator.

instanceof Operator.

Dot Operator (.).

1. Instanceof  Operator Instance Operator allow us to determine whether  the object  belong to a particular class or not. syntax

 person  instanceof  Student ;

Note-( person  instanceof  Student  ) is true if object person belong to the class Student otherwise it is false.

2. Dot Operator.  Dot Operator (.) is used to access the instance variables and methods of the class object. Example

Student person1= new  Student() ;               // person1 is object of class Student

person1.age;                                               // reference to the variable age

person1.salary() ;                                       // reference to the method  salary()

 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved