classes which implement serializable interface what exactly they implement as there are no methods in the interface.And how does it help in maintaining state of object across a network.
classes which implement serializable interface what exactly they implement as there are no methods
Share
It doesn’t maintain state itself. But it marks the class as requiring serialisation, and the runtime then knows to serialise that class, and its components (excluding fields marked as
transient).It’s useful to explicitly mark classes as being serialisable and fields as transient (i.e. not to be serialised). Otherwise you could inadvertently serialise everything in your program for transmission over the network. That likely is not what you want. You wouldn’t want to serialise entities like factories. Nor credentials like passwords. Not to mention the payload size 🙂