title: Downcasting of arrays in java
body: <p>I am not sure how downcasting of arrays works.<br>
  Example this works:  </p>
  
  <pre><code>String[] sArray = {"a", "b"};  
  Object[] o = sArray;  
  f((String[]) o);  
  
  static void f(String[] s){  
    System.out.println("Ok");   
  }  
  </code></pre>
  
  <p>But for the following:<br>
  <code>new F(cert, (X509Certificate[]) ks.getCertificateChain("ALIAS"), key));</code><br>
  where <code>F</code> is  </p>
  
  <pre><code>public F(X509Certificate certificate, X509Certificate[] certificateChain, PrivateKey privateKey) {      
  }  
  </code></pre>
  
  <p>I get <code>ClassCastException</code>  </p>
  
  <blockquote>
    <p>java.lang.ClassCastException: [Ljava.security.cert.Certificate;
    incompatible with [Ljava.security.cert.X509Certificate;</p>
  </blockquote>
  
  <p>Why?  </p>