title: Typecasting an object from parent class to child
body: <p>I have a misunderstanding about typecasting in Java language. The problem is <i>ClassCastException</I>. For example, in this code, assuming Animal is the parent class of the Dog class,</p>
  
  <pre>Animal animal = new Animal();<br>Dog dog = (Dog) animal;</pre>
  
  <p>throws <i>ClassCastException</I> after execution.
  However, while studying android packages, I found an example about typecasting which should throw a <I>ClassCastException</I>, considering that java example. </p>
  
  <pre>EditText editText = (EditText) findViewById(R.id.edit_message);</pre>
  
  <p>In this code, <i>findViewById</I> method returns a <i>View</I> class object, which is one of the superclasses of <i>EditText</I> class.(from <i>android.view.View</I> to <i>android.widget.EditText</I>) The code runs fine. Could anyone explain if I made a mistake or how this happens?</p>
  
  <p>Thanks in advance.</p>