Note for C programmers. In C a static variable declared in a functions is the same variable each time you call it. This is not available in Java. In C a static variable declared outside a function is shared by the set of functions in the same file and following the declaration an hidden from other functions. In Java a static variable is shared by all functions in that class. Whether other classes can access it depend on whether it is private, public, and/or protected. A Java variable that is nonstatic is something that is not found in C. Each object in the class has its own variable, and all functions refer to that particular variable. The variable is created as part of the object and deleted with it.
In Java instance variables are the same each time you call them. A variable or function is declared to be static when it associated with the class of objects rather than a particular object in that class. This means that a static function can not refer any data in an object - because it has no object. It also means that static data is essentially shared in common by every object but only stored in a single place. If you are in doubt about whether some data should be static or not - ask yourself how many times it occurs: once per class(static) or once per object(not static) or many time per object (its in a different class!).
. . . . . . . . . ( end of section A Glossary for the Java Language) <<Contents | End>>