How to use static variables in Processing?

Hi,

I actually did a simple example and I think I learned something.

static works in global and inside class only and doesn’t work inside a local function.

This is my example:

static class var_specs{

  static int a = 9;
  
  
};


static int b = 90;

void setup(){
  
  println(var_specs.a);
  var_specs.a++;
  println(var_specs.a);
  
  //////////////////////////////////
  
  println(b);
  b++;
  println(b);
  
  
}

void local_function(){
 static int c = 88;    // <---------------- here's the problem
 c++;
 println(c);
 
 //  it issues this error:
 //  --> Illegal modifier for parameter c; only final is permitted
  
}

Am I understanding it right ?

1 Like