Situation: I wish to send an array of objects (of different types) from a client to a server using ObjectOutputStream.
Problem : The Object array is not serializable (I get a NotSerializable Exception).
What I tried: I created a dummy class that extends Object, and implements Serializable. But I cannot cast the original objects array to this class.
Is there any way to serialize an array of Objects ?
It should not be any serialization problems with Object[]
.
Arrays are Serializable
in Java, even when the array element type is not (probably because array may theoretically hold instances of some derived Serializable class instead).
Most likely, one of the members of your array is not serializable. The stack trace should tell this, check it.