Thursday, 28 April 2016

Basic Operators in Java Programming || operator precedence

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

                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)


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



Logical Operators

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


 Operator             Meaning

   &&         Logical AND

    ||                            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 form

               Variable 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 form

                      expression1?expression2:expression3


Bitwise operators 

                  Java has a distinction of supporting special operators know as bitwise operators for manipulation of data at values of bit level. These operators are used for testing the bits, or shifting them to the right or left. bitwise operators are not applied on floating point.


Special Operators

Java supports some special operators of interest such as instanceof operator and member selection operators.

0 comments:

Post a Comment

Advertisement

Find Us On Facebook

C Programming

More

C++ Tutorial

More

Java Tutorial

More

Computer Basics

More

MS Office

More

Database Management

More
Top