title: Behavior of static blocks with inheritance
body: <p>I am trying to use static blocks like this:</p>
  
  <p>I have a base class called <code>Base.java</code></p>
  
  <pre><code>public class Base {
  
      static public int myVar;
  
  }
  </code></pre>
  
  <p>And a derived class <code>Derived.java</code>:</p>
  
  <pre><code>public class Derived extends Base {
  
      static
      {
          Base.myVar = 10;
      }
  }
  </code></pre>
  
  <p>My <code>main</code> function is like this:</p>
  
  <pre><code>public static void main(String[] args)  {
      System.out.println(Derived.myVar);
      System.out.println(Base.myVar);
  }
  </code></pre>
  
  <p>This prints the out put as <code>0 0</code> where as I expected <code>10 0</code>. Can somebody explain this behavior? Also, if I want my derived classes to set the values for a static variable how can I achieve that?</p>