title: Why is this downcast not allowed in java?
body: <p>Let's say I have a superclass of <code>Animal</code>, and a subclass of <code>Dog</code>. </p>
  
  <p>We can upcast by saying:</p>
  
  <pre><code>Animal a = new Dog();
  </code></pre>
  
  <p>We CANNOT downcast by saying:</p>
  
  <pre><code>Dog b = new Animal();
  </code></pre>
  
  <p>So I do understand that an animal does not HAVE to be a dog. But, why would having an animal "blueprint" in a dog container throw an exception? Because Dog inherits methods from Animal, when we take this animal and put it into a dog container, we know Dog inherits/overrides all methods that Animal has, so why does Java not allow this?</p>
  
  <p>Thank you!</p>