Page 76 - Trackpad_ipro 4.1_Class8
P. 76

Conditional, Looping and


                         Jumping Statements in


                                              Java                               Chapter



                                                                                  05







                                Your Aim

                                to learn about:
                                   Conditional Statements                     Loop Statements
                                   Jump Statements                            Errors in Java

                                   Writing Some More Programs



                  The programs we have written so far were executed statement by statement in a top-to-bottom
                  approach. However, sometimes we need to change the order of execution for statements or
                  repeat some statements a certain number of times. Additionally, there are some situations where
                  we need to stop the execution of certain statements. Java provides three types of statements to
                  handle these requirements:

                      Conditional Statements
                      Loop Statements

                      Jump Statements
                  Let us learn about these in detail.

                      CONDITIONAL STATEMENTS

                  Conditional statements allow us to change the default flow of a program. They transfer control of
                  a program from one statement to another, depending on the condition provided. If the provided
                  condition returns true, a block of specified statements is executed. Conditional statements are
                  also known as decision-making statements.

                  There are four decision-making statements in Java:
                      if statement

                      if … else statement
                      if … else… if statement
                      switch statement

                  Let‘s learn more about them.





                    74     iPro (Ver. 4.1)-VIII
   71   72   73   74   75   76   77   78   79   80   81