2 Switch Case
2 Switch Case
Lesson 1
Switch…case, a multi-branch selection
construct, provides an easy way to dispatch
execution to different parts of code based on
the value of a variable or the result of an
arithmetic expression.
case 2:
System.out.println(“you can talk”);
break;
case 3: What do you think default does?
System.out.println(“you can run”);
break; Do we need to add a break
default: statement after default?
System.out.println(“you can talk”);
}
Do you think default needs to be
}
written at the end only?
It is like the “else” in an “if” construct.
SUCCESS CRITERIA
LEARNING INTENTION
Students should be able to:
identify the need for a multi-branch selection
Switch…case, a multi-branch
construct
selection construct, provides an
understand the syntax of a switch case construct
easy way to dispatch execution to