title: Java Casting Interface to Class
body: <pre><code>public class InterfaceCasting {
  
      private static class A{}
  
      public static void main(String[] args) {
          A a = new A();
          Serializable serializable = new Serializable(){};
          a = (A)serializable;
      }
  
  }
  </code></pre>
  
  <p>Compilation succeed but Runtime exception</p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCastException: InterfaceCasting$1 cannot be cast to InterfaceCasting$A
  </code></pre>
  
  <p>WHY COMPILATION SUCCEED? Compiler must known that serialiazable is not A?</p>