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 › stupid question: CONSTANTS
Page Index Toggle Pages: 1
stupid question: CONSTANTS (Read 1489 times)
stupid question: CONSTANTS
Sep 24th, 2005, 6:58pm
 
Hi,

I am a newbie with Processing, and I studied Java quite a long time ago. I thought there was a keyword in java, something like "constant" (indeed I was convinced it was "constant") to define (guesswhat?) constants.

For example:

constant int MYCONSTANT;

I know it's not necessary, I can just use a variable, but I am just curious. I can't avoid feeling somewhat guilty when I declare a variable in order to define a constant...
Re: stupid question: CONSTANTS
Reply #1 - Sep 24th, 2005, 7:31pm
 
You would do "static final int MYCONSTANT = ...;"  Possibly "static final private int MYCONSTANT = ...;" if you want further compiler optimizations.

Static makes it in the class space (rather than object space), final makes it so that it cannot be changed, private allows it to not be used by other classes.

Marcello
Yeah, "final"!!!
Reply #2 - Sep 24th, 2005, 7:52pm
 
Yeah!! "FINAL", of course!! I had forgot it!!

Thank you Marcello! (non sarai italiano, per caso?)

Page Index Toggle Pages: 1