title: Does Java casting introduce overhead? Why?
body: <p>Is there any overhead when we cast objects of one type to another? Or the compiler just resolves everything and there is no cost at run time?</p>
  
  <p>Is this a general things, or there are different cases?</p>
  
  <p>For example, suppose we have an array of Object[], where each element might have a different type. But we always know for sure that, say, element 0 is a Double, element 1 is a String. (I know this is a wrong design, but let's just assume I had to do this.)</p>
  
  <p>Is Java's type information still kept around at run time? Or everything is forgotten after compilation, and if we do (Double)elements[0], we'll just follow the pointer and interpret those 8 bytes as a double, whatever that is?</p>
  
  <p>I'm very unclear about how types are done in Java. If you have any reccommendation on books or article then thanks, too.</p>