Switch Statement

A switch statement allows us to test the condition of a variable against a list of values known as case. The switch statement works with a bunch of data types such as byte, short, char, int, etc.

 

The structure of a switch statement

 

Case: Case is used to hold value within a switch statement.

Break: A break is the termination point within a switch statement. That is the stopping point for our code, the code checks a particular case to see if a given condition is met, if yes, the switch breaks, if no, the code moves the next case and the cycle continues until it reaches the termination point.

Default: This returns a value when no condition is met. That is; the end of a switch statement.

 

Click here to read more