title: Calling a Java method with no name
body: <p>I'm looking at the code below and found something a bit strange:</p>
  
  <pre><code>public class Sequence {
      Sequence() {
          System.out.print("c ");
      }
  
      {
          System.out.print("y ");
      }
  
      public static void main(String[] args) {
          new Sequence().go();
      }
  
      void go() {
          System.out.print("g ");
      }
  
      static {
          System.out.print("x ");
      }
  }
  </code></pre>
  
  <p>I would've expected this to give a compilation error as the <code>System.out</code> with "y " doesn't belong to a method declaration just a <code>{ }</code>.  Why is this valid?  I don't see how this code would or should be called.</p>
  
  <p>When running this it produces <code>x y c g</code> also, why does the <code>static { }</code> get called before the sequence constructor?</p>