The switch statement is a multiway branch statement. The general form of the switch statement is given below:
case value1://statements
break;
case value2://statements
break;
.
.
default:
//default statements
}
The expression must be of int, char, byte, or short data type and the data type of the values specified must be compatible with the expression.
Each case value must be a unique literal value. Variables are not allowed as case values.
The execution process of a switch statement is as follows:
The value of the expression is matched with each of the literal values in the case statements. If a match is found then the code sequence following that case statement is executed. If none of the values match, then the default statement is executed.
If the default statement is not given and no matching value is found, then no further action is taken.
- Click here to download master-ciw-enterprise-developer test study guide and practice question.
- Get certified in first attempt download scbcd - SCBCD simulation.
- Pass SUN scdjws - SCDJWS
- Download free practice test for SUN SCJA exam.
- Become SUN SCJP certified.
- Click here to get free scjp-5-0 SCJP 5/6 exam practice questions.
- Pass SCMAD in first attampt.
- Download free practice test for scwcd SCWCD exam.
- Download practice question and study guide for CX310-019 for exam.
- Download practice question and study guide for CX310-055 for exam.
- Pass SUN CX310-065 - SCJP 6.0