public class TypeConversion {
Human human = new Human();
NonHuman nonHuman = new NonHuman();
public void test()
{
nonHuman = (NonHuman) human; //Cannot cast from Human to NonHuman
}
}
class Human { }
class NonHuman {}
I was expecting the type conversion to work as its explicit, atleast at compile-time. And result in to a ClassCastException or some thing similar at run-time.
So, I am interested to know what are the restrictions around type conversion at compile time.