Originally posted by Tom Tolman: where is it correct and legal to do casts of a cloned object into another object? ...It appears that once you clone an array, you can assign it to an array of any superclass
Or more correctly, an array of references is assignable to an array of "references of any superclass" type.
Cloning has little to do with it.
You can assign an array of references to an array of Objects. You can't assign an array of primitives to anything, even though the elements of the array may be convertible.
For example, the elements 1,2,3 as int are convertible to lL, 2L, 3L, however an array of them is not.
However object references work sorta the opposite way. If an array has references to an object of a subclass, it can be assigned to an array of references of a superclass.
Ever since I found this suit I've felt strange new needs. And a tiny ad:
Download Free Java APIs to Work with Office Files and PDF