[Tutor] class variables

Alan Gauld alan.gauld at blueyonder.co.uk
Fri Jun 25 14:22:05 EDT 2004

> >From what you and Magnus have mentioned it seems that a so called
> variable can be created in a class scope or in a method scope. Which
> makes sense.

No, sorry not quite.

static variables in Java equate to class variables in Python.
THese are completely different to the local variables that you
can create inside a method. Local variables dissappear after
the method finishes executing. class variables are there for
as long as the class (not just the instances!) exists.

BTW static is a pretty meaningless term in Java, it is really
borrowed from C++ which borrowed it from C to indicate a
variable created on the memory heap as opposed to the stack.
It was statically located in memory. Since this doesn't apply
in Java the term static is kind of pointless!

Alan G.

More information about the Tutor mailing list