title: static initialization in interface
body: <p>When I tried to write something like this:</p>
  
  <pre><code>public interface MyInterface {
      static {
          System.out.println("Hello!");
      }
  }
  </code></pre>
  
  <p>the compiler could not compile it.</p>
  
  <p>But when I wrote something like this:</p>
  
  <pre><code>interface MyInterface {
      Integer iconst = Integer.valueOf(1);
  }
  </code></pre>
  
  <p>and decompiled it, I saw static initialization:</p>
  
  <pre><code>public interface MyInterface{
      public static final java.lang.Integer i;
  
      static {};
        Code:
        0:   iconst_1
        1:   invokestatic    #1; //Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
        4:   putstatic       #2; //Field i:Ljava/lang/Integer;
        7:   return
  }
  </code></pre>
  
  <p>Could you please explain this behavior to me?</p>