Casting variables in Java
<p>I wonder if anyone could tell me why casting works? I understand <em>WHEN</em> I should do it, but not really why it works. On primitive datatypes I understand partially but when it comes to casting objects I don't understand why it works.</p>

<p>How can a object with the type Object just suddenly be casted to lets say MyType(just an example) and then get all the methods?</p>

<p>Thank you for your time.</p>
