title: Cast primitive type array into object array in java
body: <p>Why I cannot do this in java?</p>
  
  <pre><code>Object[] o = (Object[])(new int[]{0,1,2,3.14,4});
  </code></pre>
  
  <p>I have a method that receives an object and then represents it as a string, but depending on his type (primitive, primitive wrapper, array, etc...). When I was creating a Unit test, I was passing an array as <strong>Object</strong> which is Ok, but when I perform cast of that object into <strong>Object[]</strong> I'm getting <strong>ClassCastException</strong>. 
  This is only happening with primitive type arrays. Is there any way to avoid this behavior? If not, could someone explain what is the reason of this behavior on Java Virtual Machine.</p>
  
  <p>Any help is very appreciated.</p>