Static fields and methods

The modifier static applies to fields and methods. In both cases, it marks the field or method as belonging to the class, not the instance. There is only one copy of a class field, which is shared by all instances of that class.

Class variables can hide instance variables, and instance variables can hid class variables, but this might cause confusion and should be avoided.

Examples

Methods marked with the modifier static are called class methods. Class methods do not run inside a class instance. There is no this in a class method. A class method cannot access any of the instance variables of its class.

Class methods do not override, they hide, similar to fields. You cannot try to override (hide) an instance method by a class method, or a class method by an instance method.

Examples

The final modifier can apply to fields, methods or classes. A final field cannot be modified. Its value is fixed. It is a constant. A final field must have an initializer with its declaration, that is, you must declare it like:
    final int I = 0 ;
since after its declaration, it cannot change its value.

A final method cannot be overriden. A final class cannot be extended. These are useful