title: Casting variables in Java
body: <p>I wonder if anyone could tell me how casting works? I understand <em>when</em> I should do it, but not really how it works. On primitive data types I understand partially but when it comes to casting objects I don't understand how it works.</p>
  
  <p>How can a object with the type Object just suddenly be cast to, let's say, <code>MyType</code> (just an example) and then get all the methods?</p>