0

Possible Duplicate:
Why Java needs Serializable interface?

What are the negative consequences to serialize an object? There must be some place or Sun all serializable objects. The Serializable interface need not even exist.

Community
  • 1
  • 1

2 Answers2

1

Some objects can not be safely serialized without extra code, for example if they have an open socket. If you serialize and deserialize the object, the socket will not magically have opened again.

Sjoerd
  • 74,049
  • 16
  • 131
  • 175
1

Serialization provides a second means (after the constructors) to instantiate objects. If you have created a singleton class, this can result in more than one object existing when you don't expect it.

matt freake
  • 4,877
  • 4
  • 27
  • 56