![]() |
subject > programming language construct > data item > variable > Java variable |
![]() ![]() | |||||||||||
Java variable comparison table |
Subject | serve as | have | be | implement | overuse | declared | have purpose | access by | declared in | mark as | share by |
---|---|---|---|---|---|---|---|---|---|---|---|
Java class variable | a global variable | a value that is shared by all instances of a class | as private as possible | storing: | specifying the name of the class, followed by a dot, followed by the name of the variable | the body of the class (not inside a method) | static | all instances of the class | |||
Java instance variable | an interface as its type which means that, with the variable, you can invoke any operation supported by the interface | as private as reasonably possible - almost never make them public | an attribute or association | private | other variables and methods in any class in the same package by default |
Next variable: reference Up: variable Previous variable: instance variable