title: Generics as result of java.lang.Object cannot be cast to [Ljava.lang.Object
body: <p>Could anybode exlain why generic <code>&lt;Object[]&gt;</code>  causes a <code>ClassCastException</code> (RuntimeException!)</p>
  
  <p>I know that all generics removing while compilation phase and do not have any effect to the bytecode. But it seems it has some nuance.</p>
  
  <p>Here my example (simplified for this post):</p>
  
  <pre><code>public class CastTest {
      public static void main(String[] args) {
          List a = new ArrayList();
          a.add(new Object());
          List&lt;Object[]&gt; b = a;
          b.get(0).toString();
      }
  }
  </code></pre>
  
  <p>this code returns: </p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCastException: java.lang.Object cannot be cast to [Ljava.lang.Object;
      at CastTest.main(CastTest.java:9)
  </code></pre>
  
  <p>I do not understand what is wrong with this code. Could anybody explain this behavior?</p>