println("None"); // don't match the switch parameter
break;
}
]]></code>
</example>
<example>
<image></image>
<code><![CDATA[
// Removing a "break" enables testing
// for more than one value at once
char letter = 'b';
switch(letter) {
case 'a':
case 'A':
println("Alpha"); // Does not execute
break;
case 'b':
case 'B':
println("Bravo"); // Prints "Bravo"
break;
}
]]></code>
</example>
<description><![CDATA[
Works like an <b>if else</b> structure, but <b>switch</b> is more convenient when you need to select between three or more alternatives. Program controls jumps to the case with the same value as the expression. All remaining statements in the switch are executed unless redirected by a <b>break</b>. Only primitive datatypes which can convert to an integer (byte, char, and int) may be used as the <b>expression</b> parameter. The default is optional.
]]></description>
<syntax>
switch(<c>expression</c>)
{
case <c>label</c>:
<c>statements</c>
case <c>label</c>: // Optional
<c>statements</c> // "
default: // "
<c>statements</c> // "
}
</syntax>
<parameter>
<label>expression</label>
<description><![CDATA[byte, char, or int]]></description>
</parameter>
<parameter>
<label>label</label>
<description><![CDATA[byte, char, or int]]></description>
</parameter>
<parameter>
<label>statements</label>
<description><![CDATA[one or more statements to be executed]]></description>