In Java, the switch statement is used to select one of many code blocks to be executed based on the value of a variable. The expression inside the switch must evaluate to a single value. The switch statement compares the value to the values specified in each case and executes the corresponding block of code. If no match is found, the default case (if provided) is executed. The break statement is used to exit the switch after a case is matched, preventing the code from “falling through” to subsequent cases unless explicitly intended.
6.Switch case and Conditional operator.docx