forked from processing/processing-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswitch.xml
More file actions
executable file
·118 lines (94 loc) · 2.33 KB
/
switch.xml
File metadata and controls
executable file
·118 lines (94 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>switch</name>
<category>Control</category>
<subcategory>Conditionals</subcategory>
<usage>Web & Application</usage>
<example>
<image></image>
<code><![CDATA[
int num = 1;
switch(num) {
case 0:
println("Zero"); // Does not execute
break;
case 1:
println("One"); // Prints "One"
break;
}
]]></code>
</example>
<example>
<image></image>
<code><![CDATA[
char letter = 'N';
switch(letter) {
case 'A':
println("Alpha"); // Does not execute
break;
case 'B':
println("Bravo"); // Does not execute
break;
default: // Default executes if the case labels
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>
</parameter>
<returns></returns>
<related>
case
default
break
if
else
</related>
<availability>1.0</availability>
<type>Function</type>
<partof>Java</partof>
<level>extended</level>
</root>