The Switch Statement
Java keyword
• The switch statement provides another way to decide
which statement to execute next
• The switch statement evaluates an expression and then
attempts to match the result with several cases.
• The match must be an exact match.
The Switch Statement
The Switch Statement
Switch and
Case are reserved
keywords
The Switch Statement
 The Break Statement can be
used at the end of each case.
 The break Statement causes
control to transfer to the End
of the switch statement.
 With No break statement is
used then flow will continue
to next case.
The Switch Statement:-
Default case:-
A switch statement can have optional
default case
If default case is present, and
expression matches with no other
case then default case will work.
If there is no Default case, then the
control goes to the statement after
the Switch statement
The Switch Statement:-
• The expression of the switch statement Must be in an integral type,
meaning an integer (Byte, Short, Int, Long and Char).
• It cannot be Boolean value and floating point value(double or float).
• The implicit Boolean condition is equality.
• You cannot perform relational checks with the switch expression.
The Switch Statement

The Switch Statement in java

  • 1.
  • 2.
    • The switchstatement provides another way to decide which statement to execute next • The switch statement evaluates an expression and then attempts to match the result with several cases. • The match must be an exact match. The Switch Statement
  • 3.
    The Switch Statement Switchand Case are reserved keywords
  • 4.
    The Switch Statement The Break Statement can be used at the end of each case.  The break Statement causes control to transfer to the End of the switch statement.  With No break statement is used then flow will continue to next case.
  • 5.
    The Switch Statement:- Defaultcase:- A switch statement can have optional default case If default case is present, and expression matches with no other case then default case will work. If there is no Default case, then the control goes to the statement after the Switch statement
  • 6.
    The Switch Statement:- •The expression of the switch statement Must be in an integral type, meaning an integer (Byte, Short, Int, Long and Char). • It cannot be Boolean value and floating point value(double or float). • The implicit Boolean condition is equality. • You cannot perform relational checks with the switch expression.
  • 7.