Page 81 - Trackpad_ipro 4.1_Class8
P. 81

[statements]

                    break;
                 default:

                    [statements]

                 }


                                         Start





                                       Expression







                                                    Matched
                                         Case-1                 Statement-1       Break



                                             Unmatched



                                                    Matched
                                         Case-2                 Statement-2       Break


                                             Unmatched



                                                    Matched
                                         Case-n                 Statement-n       Break



                                             Unmatched



                                        Default                  Statement




                                                                                           Stop


                 For example:
                 public class SwitchStatement
                 {
                      public static void main(int dayNumber)
                     {
                         switch (dayNumber) {




                                                             Conditional, Looping and Jumping Statements in Java  79
   76   77   78   79   80   81   82   83   84   85   86