We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › static / class vars
Page Index Toggle Pages: 1
static / class vars (Read 1905 times)
static / class vars
Apr 25th, 2005, 3:44am
 
is it possible to use class vars in tabs?

Code:

class ClassOne {
private static int staticInt = 0;

public ClassOne () {}
}


yields:
Quote:
Semantic Error: This static variable declaration is invalid, because it is not final, but is enclosed in an inner class, "ClassOne", located at...


searched forums but no luck...?
Re: static / class vars
Reply #1 - Apr 25th, 2005, 3:57am
 
code from tabs is embedded into the main sketch file, so ClassOne will be an "inner class" which can't have static variables.

you should be able to move the "private static int" variables outside ClassOne and it should run there fine, with the same effect. i.e.:

Code:
int staticInt = 0;

class ClassOne {
public ClassOne() { }
Re: static / class vars
Reply #2 - Apr 25th, 2005, 3:59am
 
This has to do with the way that Processing uses the class structure. Any time you declare a class in Processing it really becomes an inner class that is encapsulated within the base class (where void setup() and void draw() are). It may be possible to work around this in Java mode, but I haven't tried it.

http://processing.org/reference/environment/index.html#Programming_modes
Page Index Toggle Pages: 1