Both arrays must contain reference types (not primitives),
and it must be legal to cast an element of Oldtype to an element of Newtype.
public class MainClass {
public static void main(String[] argv) {
MyClass[] myClassArray = new MyClass[3];
MySubclass[] mySubclassArray = new MySubclass[3];
myClassArray = (MyClass[]) mySubclassArray;
System.out.println();
}
}
class MyClass {
}
class MySubclass extends MyClass {
}
|