One use is to hold code that you want to run immediately when the class is loaded,
before any objects are instantiated. For an inheritance tree, this means that the
order of execution of the static blocks is from subclass on up. (Execution of any
non-static blocks is from superclass on down.) How is this useful? I'd just say,
very special situations.
Jim Hoglund wrote:One use is to hold code that you want to run immediately when the class is loaded,
before any objects are instantiated. For an inheritance tree, this means that the
order of execution of the static blocks is from subclass on up. (Execution of any
non-static blocks is from superclass on down.) How is this useful? I'd just say,
very special situations.