Forums Register Login

Serializable interface

+Pie Number of slices to send: Send
When we need to implement Serializable interface by a class??
+Pie Number of slices to send: Send
Please ask questions at this level in the Java In General (Beginners) forum.
+Pie Number of slices to send: Send
Serializable is a tagging interface; it prescribes no methods. It serves to assign the Serializable data type to the tagged class and to identify the class as one which the developer has designed for persistence. ObjectOutputStream serializes only those objects which implement this interface.

Cheers,
JD
+Pie Number of slices to send: Send
You'll need to make sure that all of your member variables are also Serializable or use the "transient" keyword to indicate they can be skipped when serializing. You'll get a NotSerializableException if there is a non-serializable object anywhere in your object graph - your member variables and their member variables and so on.

You can extend a non-serializable class and make it serializable by doing custom serialization in writeObject and readObject methods.

Whew. Does it still sound worth doing?
+Pie Number of slices to send: Send
If you want to serialize a Singleton object ( google for Singleton pattern ) you must provide a readResolve method or else a new object is created.
Without deviation from the norm, progress is not possible - Zappa. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 927 times.
Similar Threads
RMI:at client side getting exceptrion like java.io.NotSerializableException
Failed to marshal exception problem
Are collections Serializable Objects
Serielizible?
I meet a problem. It is very interesting!!!!!!!!!!!!!!!!
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 09:59:46.