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.
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database