Object Oriented Software Engineering   View all facts   Glossary   Help
subject > programming language construct > data item > variable > class variable > Java class variable
Upclass variable, Java variable

Java class variable
subjectfact 
Java class variablecan serve as a global variable2001-08-30 14:56:11.0
is a subtopic of The Basics of Java2001-08-30 14:56:11.0
is accessed by specifying the name of the class, followed by a dot, followed by the name of the variablelink: chapter2section2.8.html#626, 2001-08-30 14:56:11.0
is declared in the body of the class (not inside a method)link: chapter2section2.8.html#625, 2001-08-30 14:56:11.0
is marked as staticlink: chapter2section2.8.html#625, 2001-08-30 14:56:11.0
is a kind of class variable2001-08-30 14:56:11.0
is a kind of Java variable2001-08-30 14:56:11.0
Java variablecan have an interface as its type which means that, with the variable, you can invoke any operation supported by the interface2001-08-30 14:56:22.0
is declared by giving the data type followed by the name of the variable2001-08-30 14:56:22.0
should be as private as possible2001-08-30 14:56:22.0
class variablehas a value that is shared by all instances of a class2001-08-30 14:54:52.0
has purpose storing:
  • Default or 'constant' values that are widely used by methods in a class
  • Lookup tables and similar structures used by algorithms inside a particular class
2001-08-30 14:54:52.0
is shared by all instances of the class2001-08-30 14:54:52.0
should not be overused2001-08-30 14:54:52.0
variablecan contain different classes of objects depending on the type of the variable2001-08-30 14:58:18.0
can refer to a particular object, several different objects during the execution of a program, or no object at all2001-08-30 14:58:18.0
has scope2001-08-30 14:58:18.0
has type2001-08-30 14:58:19.0

Upclass variable, Java variable