Originally posted by Jeroen T Wenting: In other words, you can try but it won't work. Both Object and String derive from Array so there's no parent-child relationship between them.
A common mistake people make with casting arrays is assuming that if an array *contains* only Strings, then it can be successfully cast to String. As the above example shows, that's not enough. Arrays (even empty arrays) have a specific component type, which must be String for that cast to work.
If you could successfully cast an array to String when it contains only Strings, explain the following code:
This will make sure that there is no classcast exception, as toString() method is defined in Object class... but make sure during your object modelling and design, that toString() is aptly overridden to return the right data you require.