static variable and method : static « Modifiers « SCJP






static methods' behaviors that are not affected by the state of any instances.

static variables hold data that is class specific as opposed to instance specific.

All static members belong to the class, not to any instance.

A static method can't access an instance variable directly.

Use the dot operator to access static members:

static methods can't be overridden, but they can be redefined.



Things you can mark as static:
methods
Variables
A class nested within another class, but not within a method.
Initialization blocks



Things you can't mark as static:

Constructors
Classes unless they are nested
Interfaces
Method local inner classes
Inner class methods and instance variables
Local variables








3.8.static
3.8.1.static variable and method
3.8.2.Declare and uses a static counter variable
3.8.3.An example of illegal access of a nonstatic variable from a static method
3.8.4.Accessing Static Methods and Variables
3.8.5.Use the dot operator on the class name, as opposed to using it on a reference to an instance
3.8.6.An example of a redefined static method
3.8.7.static features is part of a class, not individual instance of the class.
3.8.8.You can reference a static variable via a reference to any instance of the class.
3.8.9.Static methods are not allowed to use the nonstatic features of their class.
3.8.10.A static method must specify which instance of its class owns the variable or executes the method.
3.8.11.Static Initializers
3.8.12.Non-static methods may access both static and non-static variables.
3.8.13.Nested classes can be declared static, in which case they belong to the class as a whole, not any particular instance.