What do final / static / public / private tags mean?

Hi!
In the last month, I’ve been active on the forum. I saw quite a lot of things like final int b = 3, which means that b does not change. But what do the others mean? I tried using public int b = 123 inside of setup, but I received an error message. Similarly the private String abc function also got an error message. Is it somehow related that the variables defined at the top of the code are public, while the ones inside of if statements, functions, classes, … are private?

Thanks!

  • Variables defined outside functions are actually Java fields.
  • Anything inside “.pde” files are inside a PApplet subclass.
  • That’s why we can directly access PApplet members w/o the operator . dot:

https://Processing.org/reference/dot.html

1 Like

This is a concept in programming languages / computer science called scope.

Scope defines which parts of a program are accessible (readable / writable / callable) by other parts of a program.

Processing is just a layer on top of Java, so any tokens like public or private are defined by the Java language.

1 Like