-
-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathstatic.xml
More file actions
65 lines (48 loc) · 1.59 KB
/
static.xml
File metadata and controls
65 lines (48 loc) · 1.59 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
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<name>static</name>
<category>Structure</category>
<subcategory></subcategory>
<usage>Web & Application</usage>
<example>
<image></image>
<code><![CDATA[
void setup() {
MiniClass mc1 = new MiniClass();
MiniClass mc2 = new MiniClass();
println( mc1.y ); // Prints "10" to the console
MiniClass.y += 10; // The 'y' variable is shared by 'mc1' and 'mc2'
println( mc1.y ); // Prints "20" to the console
println( mc2.y ); // Prints "20" to the console
}
static class MiniClass {
static int y = 10; // Class variable
}
]]></code>
</example>
<example>
<image></image>
<code><![CDATA[
void setup() {
println(MiniClass.add(3, 4)); // Prints "7" to the console
}
static class MiniClass {
static int add(int x, int y) {
return(x + y);
}
}
]]></code>
</example>
<description><![CDATA[
Keyword used to define a variable as a "class variable" and a method as a "class method." When a variable is declared with the <b>static</b> keyword, all instances of that class share the same variable. When a class is defined with the <b>static</b> keyword, it's methods can be used without making an instance of the class. The above examples demonstrate each of these uses.<br />
<br />
This keyword is an essential part of Java programming and is not usually used with Processing. Consult a Java language reference or tutorial for more information.
]]></description>
<syntax></syntax>
<returns></returns>
<related></related>
<availability>1.0</availability>
<type>Keyword</type>
<level>Extended</level>
<partof>PDE</partof>
</root>