Switch Statements
Consider the following two examples. Both of these blocks of code would produce the same output:

Switch Statement Differences
Only 1 set of curly brackets
o To show the end of a condition use a break statement
o Without the break statement you get fall through (see example on next page)
The variable you are checking only gets mentioned once
The word default is used instead of else
Switch Statements only work with integers, characters and Strings
o Because Booleans do not work, you cannot use Conditional Operators
(<, >, ==, etc.) or Logical Operators (||, &&, etc.) in a Switch Statement
Fall Through
One major difference between IF Statements and Switch Statements is Fall Through. In an IF Statement, when you have a match on one of the conditions only code in that section (if, else if, or else) is run. However once a Switch Statement has a match, Java will continue to run lines of code until a break statement is encountered.
Consider the following:

When to Use Switch Statements
