Uses of static and non static block in Java

Static block
  1. Static block is used to initialize  the static data members and it is executed before main method starts execution.
  2. Static block can be used to reuse the common code between multiple static methods in a class.


Non Static block
  1.  Non Static block is used to reuse the common code between all constructor of class.

Comments