a port of the Processing Visualization Language
Name

static

Examples
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

}

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);

  } 

}
Description Keyword used to define a variable as a "class variable" and a method as a "class method." When a variable is declared with the static keyword, all instances of that class share the same variable. When a class is defined with the static keyword, it's methods can be used without making an instance of the class. The above examples demonstrate each of these uses.

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, such as this one.
Usage Web & Application

This reference is licensed under the CC BY-NC-SA 2.0 license:

Creative Commons License
Fork me on GitHub