Switch/Case Selection Structure
If there are A FEW, DISTINCT CASES, it makes sense to use a Switch/Case structure.
ex. 'red', 'green', 'blue' or 1,2,3
ex2 - the different stages of the gallows of Hangman based on the number of guesses remaining
switch( theVariable){
case 1:
....statements...
break;
case 2:
....statements...
break;
case 3:
....statements...
break;
default: // if theVariable DOES NOT CONTAIN ANY OF THE OTHER CASES (this is an OPTIONAL case)
....statements...
break;
}
Note:typically used for ints, chars, not Strings or doubles
Note2: If you do not include 'break;' at the end of each case, ALL CASES below the executed case will also execute. YOU NEED THE BREAK!!!