Page 85 - CA_Blue( J )_Class9
P. 85

05


                                                                       OPERATORS IN JAVA
















                           Learning Objectives



                     5.1 Operators                                       5.2 Forms of Operators
                     5.3 Types of Operators                              5.4 Special Operators in Java
                     5.5 Hierarchy of Operators                          5.6 Associativity of Operators
                     5.7 Output Statement





                 To implement the logic of a program, we may some operators to solve the problems. These operators are
                 used in the expressions which also contain identifiers, values or literals. Operators are symbols to instruct the
                 compiler to execute some operations or calculations. Let’s learn about operators and their types in detail.


                     5.1 OPERATORS
                 An expression has two parts: Operand and Operator. The variables or values that are used in the expression are
                 called Operand and the symbols on which the operand works such as + (addition), – (subtraction), etc. are known
                 as Operators. For example,
                                                               c = a + b


                 Here, a and b are operands and + is the operator.

                 Java usually has a group of built-in operators with common meaning assigned to them, though in some special
                 cases it allows programmers to assign different meanings. Let us understand with an example:

                                                double m=34.76, n= 3.6, r;

                                                int a = 1, b = 4, c;
                                                r = m * n;

                                                c = b - a;
                                                System.out.println(“The product is:” +r);

                                                System.out.println(“The difference is:” +c);





                                                                                               Operators in Java   83
   80   81   82   83   84   85   86   87   88   89   90