Syntax switch (expression) { case x: // code block break; case y: // code block break; default: // code block } This is how it works:The switch expression is evaluated once The value of the expression is compared with the values of each case If there is a match, the associated ...
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
switch(expression) { case n: code block break; case n: code block break; default: default code block } This is how it works:The switch expression is evaluated once. The value of the expression is compared with the values of each case. If there is a match, the associated block of ...
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
int day = 4; switch (day) { case 1: Console.WriteLine("Monday"); break; case 2: Console.WriteLine("Tuesday"); break; case 3: Console.WriteLine("Wednesday"); break; case 4: Console.WriteLine("Thursday"); break; case 5: Console.WriteLine("Friday"); break; case 6: Console.WriteLine...
It is possible to have multiple values for each case in the switch statement:Syntax switch expression { case x,y: // code block if expression is evaluated to x or y case v,w: // code block if expression is evaluated to v or w case z: ... default: // code block if...
int day = 4; switch (day) { case 1: System.out.println("Monday"); break; case 2: System.out.println("Tuesday"); break; case 3: System.out.println("Wednesday"); break; case 4: System.out.println("Thursday"); break; case 5: System.out.println("Friday"); break; case 6: System...
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
case2: day ="Tuesday"; break; case3: day ="Wednesday"; break; case4: day ="Thursday"; break; case5: day ="Friday"; break; case6: day ="Saturday"; } The result of day will be: Sunday Try it Yourself » The break Keyword ...