Object someStringAsObject="Hello"; String asString=(String)someStringAsObject;//works Integer asInteger=(Integer)someStringAsObject;//throws ClassCastException because it is a String and not an Integer