In complete
java 2 certification study guide, chapter 4, figure 4.10.
Newtype is an interface, Oldtype is a non-final class.
Newtype nt; Oldtype ot;
nt = (Newtype)ot; // runtime exception
It said from the book -- always ok. But I try it, but it will throw a ClassCastException. (I try it in JVM1.4)There is no relation between Newtype and Oldtype, I think. Oldtype must implemtns the interface(Newtype) and no matter Oldtype is final or non-final class.
Or this situation will exist in JVM 1.2 or older verison?
Thanks