Monday, February 11, 2019

Enumeration, static and initialize block in java


 package Interfaces;  
 enum Color{  
      RED, GREEN, BLUE;  
 }  
 public class Emunz {  
      private static String offday;  
      {  
           System.out.println("*********initializer block********************");  
      }  
      static{  
           System.out.println("****************Static block**************");  
           offday="Sunday";  
           System.out.println(offday);  
      }       
      public Emunz() {  
           System.out.println("Constructor");  
      }  
      public static void main(String[] args) {       
           Emunz emunz=new Emunz();  
           System.out.println(Color.BLUE);  
           System.out.println(Emunz.offday);  
           Emunz emunz1=new Emunz();  
      }  
 }  

No comments:

Post a Comment