Page 46 - Sanko_Sixth Edition
P. 46

LEARN BASIC JAVA PROGRAMMING                                                   <   Less than

                        Goutam Biswas                                                    <=   Less Than

                                                                                         ==   Equals
                            SESSION 2
                                                                                          !=   Not Equals
          There are some operators in Java :-

          1. Arithmetic operators
                                                                3. Logical Operators:-
              operators          Use          Example
                                                                                          Operator    Meaning
                  +            Addition       A=5 B=2
                                                                                            &&   And
                                               S=A+B
                                                                                            ||   Or
                                               S=5+2
                                                                                             !   Not
                                                 s-7

                  -           Subtraction     A=5 B=2
                                                                Conditional Statement in Java
                                               S=A-B

                                               S=5-2
                                                                In programming we required to put some condition.
                                                S=3             Hence Conditional statement are required, where a
                                                                statement or a block of statement is required to
                  *          Multiplicaion    A=5 B=2           execute if the condition is true and another
                                                                statement or block of statement is required to
                                               S=A*B
                                                                execute if the condition is false, there we required
                                               S=5*2            conditional statement.
                                                S=10
                                                                In Java we can use 3 conditional statement :
                  /            Division       A=5 B=2
                                                                   1.  If................else
                                               S=A/B
                                                                   2.  If...............else if ….............else
                                               S=5/2               3.  Switch...............case

                                               S=2.5               If..................else

                  %         Modulus(Remin     A=5 B=2
                                 der)                           Syntax to use if.........else
                                               S=A%B
                                                                if(condition)
                                               S=5%2
                                                                {
                                                S=1

                                                                true part to execute
          2. Relational Operator :-
                                                                }
                              Operator   Meaning
                                                                else
                                  >   Greater Than
                                                                {
                                  >=   Greater Than Equals




                                                                                                             40
   41   42   43   44   45   46   47   48   49   50   51