Java == Classes and 'static'

Miscellaneous Forums/General Discussion/Java == Classes and 'static'

I can't figure this one out but I'm trying to do something in Java similar to what I would do in Max
I want to create a class for handling zones where you can simply add/delete/draw/clear them by calling functions thus:

zone.add(x,y) 
zone.renderAll() 
zone.clearAll() 



In Max, you can put a global within a function and I wish to do the same with Java. Max example:

Type zone()
 Global numzones
End Type


Java has static which I understand is the same(?)

class zone{ 
  public Object [] zlist; 
  static int num=0;                  // <=== COMPLAINT HERE
  int x,y; 
  // constructor 
  public zone(){ 
    zone.zlist=new Object[25]; 
  } 


Problem is, the compiler always complains about a variable created within the class not being final

static int num=0

The compiler says the above is not valid because it is not final and is enclosed within a method
No matter what I try, I cannot get around this error
Any pointers as to where I'm going wrong?
Full example:

// zone help 
 
/// --------------------- /// 
void setup(){ 
  zone.add(28,18); 
  zone.add(42,56); 
  framerate(25); 
} 
 
/// --------------------- /// 
void draw(){ 
  background(40); 
  zone.render(); 
} 
 
// CLASSES // 
class zone{ 
  public Object [] zlist; 
  static int num=0; 
  int x,y; 
  // constructor 
  public zone(){ 
    zone.zlist=new Object[25]; 
  } 
  static void add(int xp, int yp){ 
    zlist[zone.num]=new zone(); 
    zlist.x=xp ; zlist.y=yp; 
    zone.num+=1; 
  } 
  static void render(){ 
    for (i=0;i<zone.num;i++){ 
      zone z=zlist[i]; 
      rect(z.x,z.y,32,32); 
    } 
  } 
} 


You're missing an access modifier. Choose one of:
public static int num = 0;
protected static int num = 0;
private static int num = 0;
Also never use == when comparing objects. Use Equals() instead.