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.