posted 23 years ago
All arrays are defined to implement Cloneable and Serializable. So, you can execute this code:
<code><pre> Cloneable cl = new int[10];
Serializable se = new int[10];</pre></code>
(Note that Serializable isn't mentionted in the original JLS for this, but it is in the 2nd edition draft.)
I'm not sure how useful this is - clone() is protected, and writeObject() and readObject() are private, so *we* can't actually use these methods from outside the class. And the class for an array is already implemented for us, so we can't alter its code - so we'll really never be able to call clone() or writeObject() on an array directly. However, these methods are called by the JVM whenever we clone or serialize an object which contains an array as a member. So I guess it's important that the machine recognize these members as Cloneable and Serializable so that it doesn't throw an error in these cases.
"I'm not back." - Bill Harding, Twister