Java Tutorial: Switch Case Statements in Java
Switch Case-Control Instruction
- Switch-Case is used when we have to make a choice between the number of alternatives for a given variable.
- Var can be an integer, character, or string in Java.
- Every switch case must contain a default case. The default case is executed when all the other cases are false.
- Never forget to include the break statement after every switch case otherwise the switch case will not terminate.
Syntax :
- A switch can occur within another but in practice, this is rarely done.
Flow control of switch case in Java :
Code as Described in the Video
Ultimate Java Cheatsheet: Click To Download