Hi there,
Recently I’ve been looking up some more Java4k sources for fun, and have noticed a common pattern that I don’t fully understand.
Namely, people seem to declare all their variables and constants within the run() method, rather than at the class level. Meaning this:
public class Classy
{
public void run()
{
final int CONSTANT = 0;
int VARIABLE = 1;
// etc...
}
}
Instead of this:
public class Classy
{
private final int CONSTANT = 0;
private int VARIABLE = 1;
public void run()
{
// etc...
}
}
I was wondering if there is an actual performance/memory reason for this, or if simply people develop their Java4k games within a single method and just paste it into a standard class skeleton.