title: Casting arrays in java
body: <p>would someone help me understand this behavior of Java?</p>
  <p>I found that running</p>
  <pre><code>Object[] objArray = {&quot;A&quot;, &quot;B&quot;};  
  String[] strArray = (String[]) objArray;
  </code></pre>
  <p>throws a ClassCastException (so far, so good). However,</p>
  <pre><code>String[] strArray = {&quot;A&quot;, &quot;B&quot;}; 
  Object[] objArray = strArray; 
  String[] castStrArray = (String[]) objArray;
  </code></pre>
  <p>does not. I have trouble understanding this (I do not see in which ways the 'objArray' in both versions are different). Could someone help me understand the underlying concept?</p>
  <p>Best regards!</p>