Switch case in Java at Hackveda
Sep 3, 2018 · 2 min read
Switch statement in Java is used to allow a variable for equality against a list of value.Variables used in Switch case is integer, convertible integer(short,char,byte) and String.
Syntax of Switch Case

Let understand with help of an example.
We show output of a grade of student marks obtained
- If student have A grade then Show “Excellent”
- If student have B grade then Show “Very good”
- If student have C grade then Show “Good”
- If student have B grade then Show “Average”
- If user enter other than these character then show “Enter value between A-D”

Output

Note
break — The break statement in Java is used to terminate loop immediately and move control on next statement.
default — It is used when no keyword match then default then default keyword executed.
