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 variable in no static class
Page Index Toggle Pages: 1
Static variable in no static class ? (Read 328 times)
Static variable in no static class ?
Feb 14th, 2010, 10:21am
 
Why we can't enclose static variable in non static class ?

Code:

void setup() {
 Test t = new Test();
}

class Test
{
  static int global_var = 2;
  public int obj_var;
 
  Test()
  {
    obj_var = 3;
  }
}

This code produce error :
The field global_var cannot be declared static;
static fields can only be declared in static or top level types
Re: Static variable in no static class ?
Reply #1 - Feb 14th, 2010, 10:25am
 
Already posted : http://processing.org/discourse/yabb2/num_1263237645.html

I read there to understand.
Page Index Toggle Pages: 1