Branching - switch-case-default
Syntax:
switch ( int-value ) {
case int-value1:
break;
case int-value2:
break;
default:
}
Example:
String numToString(int num) {
switch (num) {
case 1: return "one";
case 2: return "two";
……………………..
case 50: return “fifty”;
default: return "many";
}
}
Previous slide
Next slide
Back to first slide
View graphic version