The switch and if-else both are selection statement and they
both let you select an alternative out of given many alternative by testing an
expression.
Below I have Listed Some of the Difference in their
operations:
The switch statement
differs from the if statement in
that switch can only test for
equality whereas if can evaluate a
relation or logical expression.
The Switch statement
selects its branches by testing the values of same variable but If –else construction lets you use a
series of expressions that may involve unrelated variables and complex
expressions.
If Else is more versatile where as Switch label must be
single value
Switch case Label must be constant , to compare two variable
just use if-else
Switch is more efficient choice for code used in testing a
value against a set of constant
If the Character are used in switch they are automatically
changed into equivalent ASCII coding