if you stay inside pde (ie: you don't develop under eclipse or netbeans), you keep your sketch simple and you don't integrate your sketch inside a bigger java project, you won't probably crash into static stuff.
on the other side, learning how to correctly declare a variable (or function) can save you a few headaches later
so here we go:
- static: a 'static' method or variable is not linked to a single object but is attached to a whole class. i know this sounds a little exoteric the first time you hear it, so i'll try to make it easier with and example: suppose you create a class like this:
Code:class Example{
int counter;
...
Exampe(){
counter++;
println(counter);
}
...
}
then instantiate a few objects:
Code:
...
obj1 = new Example();
obj2 = new Example();
obj3 = new Example();
...
now, in the console you'll see 3 lines containg the same value right? each object creates its 'counter' and increments it the same way.
things would be differente if the counter was satic:
Code:
class Example{
static int counter;
...
Exampe(){
counter++;
println(counter);
}
...
}
...
obj1 = new Example();
obj2 = new Example();
obj3 = new Example();
...
now in the console you'll read something like
Code:
1
2
3
because the static int counter deals directly with the example class and has nothing to do with single objects. obj1's constructor increments counter from 0 to 1, so when obj2's constructor is called counter is equal to 1, and is incremented to 2, and so on.
- final: this keyword means that the variable cannot be changed, making its behaviour similar to a constant