Learn java app

Program to know the functionality of Static Block

◀ ▷ ▶ ♤ ♠ ♡ ♥ ♧ ♣ ⊙e 2020. 6. 22. 07:26
반응형

 


Program: 
class StaticBlock {
  public static void main(String[] args) {
    System.out.println("Main method is executed.");
    }
 
  static {
    System.out.println("Static block is executed before main method.");
  }
}

Output: 
Static block is executed before main method.
Main method is executed.